
obj/user/echo:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 e3 00 00 00       	call   800114 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <umain>:
#include <inc/lib.h>

void
umain(int argc, char **argv)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	57                   	push   %edi
  800044:	56                   	push   %esi
  800045:	53                   	push   %ebx
  800046:	83 ec 2c             	sub    $0x2c,%esp
  800049:	8b 7d 08             	mov    0x8(%ebp),%edi
  80004c:	8b 75 0c             	mov    0xc(%ebp),%esi
	int i, nflag;

	nflag = 0;
	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
  80004f:	83 ff 01             	cmp    $0x1,%edi
  800052:	0f 8e 8b 00 00 00    	jle    8000e3 <umain+0xa3>
  800058:	8d 5e 04             	lea    0x4(%esi),%ebx
  80005b:	c7 44 24 04 c0 28 80 	movl   $0x8028c0,0x4(%esp)
  800062:	00 
  800063:	8b 03                	mov    (%ebx),%eax
  800065:	89 04 24             	mov    %eax,(%esp)
  800068:	e8 ec 01 00 00       	call   800259 <strcmp>
			write(1, " ", 1);
		write(1, argv[i], strlen(argv[i]));
	}
	if (!nflag)
		write(1, "\n", 1);
}
  80006d:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
umain(int argc, char **argv)
{
	int i, nflag;

	nflag = 0;
	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
  800074:	85 c0                	test   %eax,%eax
  800076:	0f 85 85 00 00 00    	jne    800101 <umain+0xc1>
		nflag = 1;
		argc--;
  80007c:	83 ef 01             	sub    $0x1,%edi
		argv++;
	}
	for (i = 1; i < argc; i++) {
  80007f:	83 ff 01             	cmp    $0x1,%edi
  800082:	0f 8e 80 00 00 00    	jle    800108 <umain+0xc8>
  800088:	89 de                	mov    %ebx,%esi
  80008a:	c7 45 e4 01 00 00 00 	movl   $0x1,-0x1c(%ebp)
  800091:	eb 6e                	jmp    800101 <umain+0xc1>
		if (i > 1)
  800093:	83 fb 01             	cmp    $0x1,%ebx
  800096:	7e 1c                	jle    8000b4 <umain+0x74>
			write(1, " ", 1);
  800098:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  80009f:	00 
  8000a0:	c7 44 24 04 30 2a 80 	movl   $0x802a30,0x4(%esp)
  8000a7:	00 
  8000a8:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8000af:	e8 16 0c 00 00       	call   800cca <write>
		write(1, argv[i], strlen(argv[i]));
  8000b4:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  8000b7:	89 04 24             	mov    %eax,(%esp)
  8000ba:	e8 c1 00 00 00       	call   800180 <strlen>
  8000bf:	89 44 24 08          	mov    %eax,0x8(%esp)
  8000c3:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  8000c6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000ca:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8000d1:	e8 f4 0b 00 00       	call   800cca <write>
	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
		nflag = 1;
		argc--;
		argv++;
	}
	for (i = 1; i < argc; i++) {
  8000d6:	83 c3 01             	add    $0x1,%ebx
  8000d9:	39 fb                	cmp    %edi,%ebx
  8000db:	7c b6                	jl     800093 <umain+0x53>
		if (i > 1)
			write(1, " ", 1);
		write(1, argv[i], strlen(argv[i]));
	}
	if (!nflag)
  8000dd:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8000e1:	75 25                	jne    800108 <umain+0xc8>
		write(1, "\n", 1);
  8000e3:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8000ea:	00 
  8000eb:	c7 44 24 04 fe 29 80 	movl   $0x8029fe,0x4(%esp)
  8000f2:	00 
  8000f3:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8000fa:	e8 cb 0b 00 00       	call   800cca <write>
  8000ff:	eb 07                	jmp    800108 <umain+0xc8>
}
  800101:	bb 01 00 00 00       	mov    $0x1,%ebx
  800106:	eb ac                	jmp    8000b4 <umain+0x74>
  800108:	83 c4 2c             	add    $0x2c,%esp
  80010b:	5b                   	pop    %ebx
  80010c:	5e                   	pop    %esi
  80010d:	5f                   	pop    %edi
  80010e:	5d                   	pop    %ebp
  80010f:	90                   	nop
  800110:	c3                   	ret    
  800111:	00 00                	add    %al,(%eax)
	...

00800114 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800114:	55                   	push   %ebp
  800115:	89 e5                	mov    %esp,%ebp
  800117:	83 ec 18             	sub    $0x18,%esp
  80011a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80011d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800120:	8b 75 08             	mov    0x8(%ebp),%esi
  800123:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800126:	e8 8e 08 00 00       	call   8009b9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  80012b:	25 ff 03 00 00       	and    $0x3ff,%eax
  800130:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800133:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800138:	a3 74 60 80 00       	mov    %eax,0x806074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  80013d:	85 f6                	test   %esi,%esi
  80013f:	7e 07                	jle    800148 <libmain+0x34>
		binaryname = argv[0];
  800141:	8b 03                	mov    (%ebx),%eax
  800143:	a3 00 60 80 00       	mov    %eax,0x806000

	// call user main routine
	umain(argc, argv);
  800148:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80014c:	89 34 24             	mov    %esi,(%esp)
  80014f:	e8 ec fe ff ff       	call   800040 <umain>

	// exit gracefully
	exit();
  800154:	e8 0b 00 00 00       	call   800164 <exit>
}
  800159:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80015c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80015f:	89 ec                	mov    %ebp,%esp
  800161:	5d                   	pop    %ebp
  800162:	c3                   	ret    
	...

00800164 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800164:	55                   	push   %ebp
  800165:	89 e5                	mov    %esp,%ebp
  800167:	83 ec 18             	sub    $0x18,%esp
	close_all();
  80016a:	e8 1a 0e 00 00       	call   800f89 <close_all>
	sys_env_destroy(0);
  80016f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800176:	e8 72 08 00 00       	call   8009ed <sys_env_destroy>
}
  80017b:	c9                   	leave  
  80017c:	c3                   	ret    
  80017d:	00 00                	add    %al,(%eax)
	...

00800180 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800180:	55                   	push   %ebp
  800181:	89 e5                	mov    %esp,%ebp
  800183:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800186:	b8 00 00 00 00       	mov    $0x0,%eax
  80018b:	80 3a 00             	cmpb   $0x0,(%edx)
  80018e:	74 09                	je     800199 <strlen+0x19>
		n++;
  800190:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800193:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800197:	75 f7                	jne    800190 <strlen+0x10>
		n++;
	return n;
}
  800199:	5d                   	pop    %ebp
  80019a:	c3                   	ret    

0080019b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80019b:	55                   	push   %ebp
  80019c:	89 e5                	mov    %esp,%ebp
  80019e:	53                   	push   %ebx
  80019f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8001a2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8001a5:	85 c9                	test   %ecx,%ecx
  8001a7:	74 19                	je     8001c2 <strnlen+0x27>
  8001a9:	80 3b 00             	cmpb   $0x0,(%ebx)
  8001ac:	74 14                	je     8001c2 <strnlen+0x27>
  8001ae:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  8001b3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8001b6:	39 c8                	cmp    %ecx,%eax
  8001b8:	74 0d                	je     8001c7 <strnlen+0x2c>
  8001ba:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  8001be:	75 f3                	jne    8001b3 <strnlen+0x18>
  8001c0:	eb 05                	jmp    8001c7 <strnlen+0x2c>
  8001c2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  8001c7:	5b                   	pop    %ebx
  8001c8:	5d                   	pop    %ebp
  8001c9:	c3                   	ret    

008001ca <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  8001ca:	55                   	push   %ebp
  8001cb:	89 e5                	mov    %esp,%ebp
  8001cd:	53                   	push   %ebx
  8001ce:	8b 45 08             	mov    0x8(%ebp),%eax
  8001d1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8001d4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8001d9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  8001dd:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8001e0:	83 c2 01             	add    $0x1,%edx
  8001e3:	84 c9                	test   %cl,%cl
  8001e5:	75 f2                	jne    8001d9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8001e7:	5b                   	pop    %ebx
  8001e8:	5d                   	pop    %ebp
  8001e9:	c3                   	ret    

008001ea <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8001ea:	55                   	push   %ebp
  8001eb:	89 e5                	mov    %esp,%ebp
  8001ed:	56                   	push   %esi
  8001ee:	53                   	push   %ebx
  8001ef:	8b 45 08             	mov    0x8(%ebp),%eax
  8001f2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8001f5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8001f8:	85 f6                	test   %esi,%esi
  8001fa:	74 18                	je     800214 <strncpy+0x2a>
  8001fc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800201:	0f b6 1a             	movzbl (%edx),%ebx
  800204:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800207:	80 3a 01             	cmpb   $0x1,(%edx)
  80020a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  80020d:	83 c1 01             	add    $0x1,%ecx
  800210:	39 ce                	cmp    %ecx,%esi
  800212:	77 ed                	ja     800201 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800214:	5b                   	pop    %ebx
  800215:	5e                   	pop    %esi
  800216:	5d                   	pop    %ebp
  800217:	c3                   	ret    

00800218 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800218:	55                   	push   %ebp
  800219:	89 e5                	mov    %esp,%ebp
  80021b:	56                   	push   %esi
  80021c:	53                   	push   %ebx
  80021d:	8b 75 08             	mov    0x8(%ebp),%esi
  800220:	8b 55 0c             	mov    0xc(%ebp),%edx
  800223:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800226:	89 f0                	mov    %esi,%eax
  800228:	85 c9                	test   %ecx,%ecx
  80022a:	74 27                	je     800253 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  80022c:	83 e9 01             	sub    $0x1,%ecx
  80022f:	74 1d                	je     80024e <strlcpy+0x36>
  800231:	0f b6 1a             	movzbl (%edx),%ebx
  800234:	84 db                	test   %bl,%bl
  800236:	74 16                	je     80024e <strlcpy+0x36>
			*dst++ = *src++;
  800238:	88 18                	mov    %bl,(%eax)
  80023a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  80023d:	83 e9 01             	sub    $0x1,%ecx
  800240:	74 0e                	je     800250 <strlcpy+0x38>
			*dst++ = *src++;
  800242:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800245:	0f b6 1a             	movzbl (%edx),%ebx
  800248:	84 db                	test   %bl,%bl
  80024a:	75 ec                	jne    800238 <strlcpy+0x20>
  80024c:	eb 02                	jmp    800250 <strlcpy+0x38>
  80024e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800250:	c6 00 00             	movb   $0x0,(%eax)
  800253:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800255:	5b                   	pop    %ebx
  800256:	5e                   	pop    %esi
  800257:	5d                   	pop    %ebp
  800258:	c3                   	ret    

00800259 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800259:	55                   	push   %ebp
  80025a:	89 e5                	mov    %esp,%ebp
  80025c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80025f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800262:	0f b6 01             	movzbl (%ecx),%eax
  800265:	84 c0                	test   %al,%al
  800267:	74 15                	je     80027e <strcmp+0x25>
  800269:	3a 02                	cmp    (%edx),%al
  80026b:	75 11                	jne    80027e <strcmp+0x25>
		p++, q++;
  80026d:	83 c1 01             	add    $0x1,%ecx
  800270:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800273:	0f b6 01             	movzbl (%ecx),%eax
  800276:	84 c0                	test   %al,%al
  800278:	74 04                	je     80027e <strcmp+0x25>
  80027a:	3a 02                	cmp    (%edx),%al
  80027c:	74 ef                	je     80026d <strcmp+0x14>
  80027e:	0f b6 c0             	movzbl %al,%eax
  800281:	0f b6 12             	movzbl (%edx),%edx
  800284:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800286:	5d                   	pop    %ebp
  800287:	c3                   	ret    

00800288 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800288:	55                   	push   %ebp
  800289:	89 e5                	mov    %esp,%ebp
  80028b:	53                   	push   %ebx
  80028c:	8b 55 08             	mov    0x8(%ebp),%edx
  80028f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800292:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800295:	85 c0                	test   %eax,%eax
  800297:	74 23                	je     8002bc <strncmp+0x34>
  800299:	0f b6 1a             	movzbl (%edx),%ebx
  80029c:	84 db                	test   %bl,%bl
  80029e:	74 24                	je     8002c4 <strncmp+0x3c>
  8002a0:	3a 19                	cmp    (%ecx),%bl
  8002a2:	75 20                	jne    8002c4 <strncmp+0x3c>
  8002a4:	83 e8 01             	sub    $0x1,%eax
  8002a7:	74 13                	je     8002bc <strncmp+0x34>
		n--, p++, q++;
  8002a9:	83 c2 01             	add    $0x1,%edx
  8002ac:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  8002af:	0f b6 1a             	movzbl (%edx),%ebx
  8002b2:	84 db                	test   %bl,%bl
  8002b4:	74 0e                	je     8002c4 <strncmp+0x3c>
  8002b6:	3a 19                	cmp    (%ecx),%bl
  8002b8:	74 ea                	je     8002a4 <strncmp+0x1c>
  8002ba:	eb 08                	jmp    8002c4 <strncmp+0x3c>
  8002bc:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  8002c1:	5b                   	pop    %ebx
  8002c2:	5d                   	pop    %ebp
  8002c3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  8002c4:	0f b6 02             	movzbl (%edx),%eax
  8002c7:	0f b6 11             	movzbl (%ecx),%edx
  8002ca:	29 d0                	sub    %edx,%eax
  8002cc:	eb f3                	jmp    8002c1 <strncmp+0x39>

008002ce <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  8002ce:	55                   	push   %ebp
  8002cf:	89 e5                	mov    %esp,%ebp
  8002d1:	8b 45 08             	mov    0x8(%ebp),%eax
  8002d4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8002d8:	0f b6 10             	movzbl (%eax),%edx
  8002db:	84 d2                	test   %dl,%dl
  8002dd:	74 15                	je     8002f4 <strchr+0x26>
		if (*s == c)
  8002df:	38 ca                	cmp    %cl,%dl
  8002e1:	75 07                	jne    8002ea <strchr+0x1c>
  8002e3:	eb 14                	jmp    8002f9 <strchr+0x2b>
  8002e5:	38 ca                	cmp    %cl,%dl
  8002e7:	90                   	nop
  8002e8:	74 0f                	je     8002f9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  8002ea:	83 c0 01             	add    $0x1,%eax
  8002ed:	0f b6 10             	movzbl (%eax),%edx
  8002f0:	84 d2                	test   %dl,%dl
  8002f2:	75 f1                	jne    8002e5 <strchr+0x17>
  8002f4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  8002f9:	5d                   	pop    %ebp
  8002fa:	c3                   	ret    

008002fb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  8002fb:	55                   	push   %ebp
  8002fc:	89 e5                	mov    %esp,%ebp
  8002fe:	8b 45 08             	mov    0x8(%ebp),%eax
  800301:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800305:	0f b6 10             	movzbl (%eax),%edx
  800308:	84 d2                	test   %dl,%dl
  80030a:	74 18                	je     800324 <strfind+0x29>
		if (*s == c)
  80030c:	38 ca                	cmp    %cl,%dl
  80030e:	75 0a                	jne    80031a <strfind+0x1f>
  800310:	eb 12                	jmp    800324 <strfind+0x29>
  800312:	38 ca                	cmp    %cl,%dl
  800314:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800318:	74 0a                	je     800324 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  80031a:	83 c0 01             	add    $0x1,%eax
  80031d:	0f b6 10             	movzbl (%eax),%edx
  800320:	84 d2                	test   %dl,%dl
  800322:	75 ee                	jne    800312 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800324:	5d                   	pop    %ebp
  800325:	c3                   	ret    

00800326 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800326:	55                   	push   %ebp
  800327:	89 e5                	mov    %esp,%ebp
  800329:	83 ec 0c             	sub    $0xc,%esp
  80032c:	89 1c 24             	mov    %ebx,(%esp)
  80032f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800333:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800337:	8b 7d 08             	mov    0x8(%ebp),%edi
  80033a:	8b 45 0c             	mov    0xc(%ebp),%eax
  80033d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800340:	85 c9                	test   %ecx,%ecx
  800342:	74 30                	je     800374 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800344:	f7 c7 03 00 00 00    	test   $0x3,%edi
  80034a:	75 25                	jne    800371 <memset+0x4b>
  80034c:	f6 c1 03             	test   $0x3,%cl
  80034f:	75 20                	jne    800371 <memset+0x4b>
		c &= 0xFF;
  800351:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800354:	89 d3                	mov    %edx,%ebx
  800356:	c1 e3 08             	shl    $0x8,%ebx
  800359:	89 d6                	mov    %edx,%esi
  80035b:	c1 e6 18             	shl    $0x18,%esi
  80035e:	89 d0                	mov    %edx,%eax
  800360:	c1 e0 10             	shl    $0x10,%eax
  800363:	09 f0                	or     %esi,%eax
  800365:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800367:	09 d8                	or     %ebx,%eax
  800369:	c1 e9 02             	shr    $0x2,%ecx
  80036c:	fc                   	cld    
  80036d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  80036f:	eb 03                	jmp    800374 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800371:	fc                   	cld    
  800372:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800374:	89 f8                	mov    %edi,%eax
  800376:	8b 1c 24             	mov    (%esp),%ebx
  800379:	8b 74 24 04          	mov    0x4(%esp),%esi
  80037d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800381:	89 ec                	mov    %ebp,%esp
  800383:	5d                   	pop    %ebp
  800384:	c3                   	ret    

00800385 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800385:	55                   	push   %ebp
  800386:	89 e5                	mov    %esp,%ebp
  800388:	83 ec 08             	sub    $0x8,%esp
  80038b:	89 34 24             	mov    %esi,(%esp)
  80038e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800392:	8b 45 08             	mov    0x8(%ebp),%eax
  800395:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800398:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  80039b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  80039d:	39 c6                	cmp    %eax,%esi
  80039f:	73 35                	jae    8003d6 <memmove+0x51>
  8003a1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  8003a4:	39 d0                	cmp    %edx,%eax
  8003a6:	73 2e                	jae    8003d6 <memmove+0x51>
		s += n;
		d += n;
  8003a8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  8003aa:	f6 c2 03             	test   $0x3,%dl
  8003ad:	75 1b                	jne    8003ca <memmove+0x45>
  8003af:	f7 c7 03 00 00 00    	test   $0x3,%edi
  8003b5:	75 13                	jne    8003ca <memmove+0x45>
  8003b7:	f6 c1 03             	test   $0x3,%cl
  8003ba:	75 0e                	jne    8003ca <memmove+0x45>
			asm volatile("std; rep movsl\n"
  8003bc:	83 ef 04             	sub    $0x4,%edi
  8003bf:	8d 72 fc             	lea    -0x4(%edx),%esi
  8003c2:	c1 e9 02             	shr    $0x2,%ecx
  8003c5:	fd                   	std    
  8003c6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  8003c8:	eb 09                	jmp    8003d3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  8003ca:	83 ef 01             	sub    $0x1,%edi
  8003cd:	8d 72 ff             	lea    -0x1(%edx),%esi
  8003d0:	fd                   	std    
  8003d1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  8003d3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  8003d4:	eb 20                	jmp    8003f6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  8003d6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  8003dc:	75 15                	jne    8003f3 <memmove+0x6e>
  8003de:	f7 c7 03 00 00 00    	test   $0x3,%edi
  8003e4:	75 0d                	jne    8003f3 <memmove+0x6e>
  8003e6:	f6 c1 03             	test   $0x3,%cl
  8003e9:	75 08                	jne    8003f3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  8003eb:	c1 e9 02             	shr    $0x2,%ecx
  8003ee:	fc                   	cld    
  8003ef:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  8003f1:	eb 03                	jmp    8003f6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  8003f3:	fc                   	cld    
  8003f4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  8003f6:	8b 34 24             	mov    (%esp),%esi
  8003f9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  8003fd:	89 ec                	mov    %ebp,%esp
  8003ff:	5d                   	pop    %ebp
  800400:	c3                   	ret    

00800401 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800401:	55                   	push   %ebp
  800402:	89 e5                	mov    %esp,%ebp
  800404:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800407:	8b 45 10             	mov    0x10(%ebp),%eax
  80040a:	89 44 24 08          	mov    %eax,0x8(%esp)
  80040e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800411:	89 44 24 04          	mov    %eax,0x4(%esp)
  800415:	8b 45 08             	mov    0x8(%ebp),%eax
  800418:	89 04 24             	mov    %eax,(%esp)
  80041b:	e8 65 ff ff ff       	call   800385 <memmove>
}
  800420:	c9                   	leave  
  800421:	c3                   	ret    

00800422 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800422:	55                   	push   %ebp
  800423:	89 e5                	mov    %esp,%ebp
  800425:	57                   	push   %edi
  800426:	56                   	push   %esi
  800427:	53                   	push   %ebx
  800428:	8b 75 08             	mov    0x8(%ebp),%esi
  80042b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80042e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800431:	85 c9                	test   %ecx,%ecx
  800433:	74 36                	je     80046b <memcmp+0x49>
		if (*s1 != *s2)
  800435:	0f b6 06             	movzbl (%esi),%eax
  800438:	0f b6 1f             	movzbl (%edi),%ebx
  80043b:	38 d8                	cmp    %bl,%al
  80043d:	74 20                	je     80045f <memcmp+0x3d>
  80043f:	eb 14                	jmp    800455 <memcmp+0x33>
  800441:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800446:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  80044b:	83 c2 01             	add    $0x1,%edx
  80044e:	83 e9 01             	sub    $0x1,%ecx
  800451:	38 d8                	cmp    %bl,%al
  800453:	74 12                	je     800467 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800455:	0f b6 c0             	movzbl %al,%eax
  800458:	0f b6 db             	movzbl %bl,%ebx
  80045b:	29 d8                	sub    %ebx,%eax
  80045d:	eb 11                	jmp    800470 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  80045f:	83 e9 01             	sub    $0x1,%ecx
  800462:	ba 00 00 00 00       	mov    $0x0,%edx
  800467:	85 c9                	test   %ecx,%ecx
  800469:	75 d6                	jne    800441 <memcmp+0x1f>
  80046b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800470:	5b                   	pop    %ebx
  800471:	5e                   	pop    %esi
  800472:	5f                   	pop    %edi
  800473:	5d                   	pop    %ebp
  800474:	c3                   	ret    

00800475 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800475:	55                   	push   %ebp
  800476:	89 e5                	mov    %esp,%ebp
  800478:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  80047b:	89 c2                	mov    %eax,%edx
  80047d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800480:	39 d0                	cmp    %edx,%eax
  800482:	73 15                	jae    800499 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800484:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800488:	38 08                	cmp    %cl,(%eax)
  80048a:	75 06                	jne    800492 <memfind+0x1d>
  80048c:	eb 0b                	jmp    800499 <memfind+0x24>
  80048e:	38 08                	cmp    %cl,(%eax)
  800490:	74 07                	je     800499 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800492:	83 c0 01             	add    $0x1,%eax
  800495:	39 c2                	cmp    %eax,%edx
  800497:	77 f5                	ja     80048e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800499:	5d                   	pop    %ebp
  80049a:	c3                   	ret    

0080049b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  80049b:	55                   	push   %ebp
  80049c:	89 e5                	mov    %esp,%ebp
  80049e:	57                   	push   %edi
  80049f:	56                   	push   %esi
  8004a0:	53                   	push   %ebx
  8004a1:	83 ec 04             	sub    $0x4,%esp
  8004a4:	8b 55 08             	mov    0x8(%ebp),%edx
  8004a7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  8004aa:	0f b6 02             	movzbl (%edx),%eax
  8004ad:	3c 20                	cmp    $0x20,%al
  8004af:	74 04                	je     8004b5 <strtol+0x1a>
  8004b1:	3c 09                	cmp    $0x9,%al
  8004b3:	75 0e                	jne    8004c3 <strtol+0x28>
		s++;
  8004b5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  8004b8:	0f b6 02             	movzbl (%edx),%eax
  8004bb:	3c 20                	cmp    $0x20,%al
  8004bd:	74 f6                	je     8004b5 <strtol+0x1a>
  8004bf:	3c 09                	cmp    $0x9,%al
  8004c1:	74 f2                	je     8004b5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  8004c3:	3c 2b                	cmp    $0x2b,%al
  8004c5:	75 0c                	jne    8004d3 <strtol+0x38>
		s++;
  8004c7:	83 c2 01             	add    $0x1,%edx
  8004ca:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  8004d1:	eb 15                	jmp    8004e8 <strtol+0x4d>
	else if (*s == '-')
  8004d3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  8004da:	3c 2d                	cmp    $0x2d,%al
  8004dc:	75 0a                	jne    8004e8 <strtol+0x4d>
		s++, neg = 1;
  8004de:	83 c2 01             	add    $0x1,%edx
  8004e1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  8004e8:	85 db                	test   %ebx,%ebx
  8004ea:	0f 94 c0             	sete   %al
  8004ed:	74 05                	je     8004f4 <strtol+0x59>
  8004ef:	83 fb 10             	cmp    $0x10,%ebx
  8004f2:	75 18                	jne    80050c <strtol+0x71>
  8004f4:	80 3a 30             	cmpb   $0x30,(%edx)
  8004f7:	75 13                	jne    80050c <strtol+0x71>
  8004f9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  8004fd:	8d 76 00             	lea    0x0(%esi),%esi
  800500:	75 0a                	jne    80050c <strtol+0x71>
		s += 2, base = 16;
  800502:	83 c2 02             	add    $0x2,%edx
  800505:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  80050a:	eb 15                	jmp    800521 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  80050c:	84 c0                	test   %al,%al
  80050e:	66 90                	xchg   %ax,%ax
  800510:	74 0f                	je     800521 <strtol+0x86>
  800512:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800517:	80 3a 30             	cmpb   $0x30,(%edx)
  80051a:	75 05                	jne    800521 <strtol+0x86>
		s++, base = 8;
  80051c:	83 c2 01             	add    $0x1,%edx
  80051f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800521:	b8 00 00 00 00       	mov    $0x0,%eax
  800526:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800528:	0f b6 0a             	movzbl (%edx),%ecx
  80052b:	89 cf                	mov    %ecx,%edi
  80052d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800530:	80 fb 09             	cmp    $0x9,%bl
  800533:	77 08                	ja     80053d <strtol+0xa2>
			dig = *s - '0';
  800535:	0f be c9             	movsbl %cl,%ecx
  800538:	83 e9 30             	sub    $0x30,%ecx
  80053b:	eb 1e                	jmp    80055b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  80053d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800540:	80 fb 19             	cmp    $0x19,%bl
  800543:	77 08                	ja     80054d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800545:	0f be c9             	movsbl %cl,%ecx
  800548:	83 e9 57             	sub    $0x57,%ecx
  80054b:	eb 0e                	jmp    80055b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  80054d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800550:	80 fb 19             	cmp    $0x19,%bl
  800553:	77 15                	ja     80056a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800555:	0f be c9             	movsbl %cl,%ecx
  800558:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  80055b:	39 f1                	cmp    %esi,%ecx
  80055d:	7d 0b                	jge    80056a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  80055f:	83 c2 01             	add    $0x1,%edx
  800562:	0f af c6             	imul   %esi,%eax
  800565:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800568:	eb be                	jmp    800528 <strtol+0x8d>
  80056a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  80056c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800570:	74 05                	je     800577 <strtol+0xdc>
		*endptr = (char *) s;
  800572:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800575:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800577:	89 ca                	mov    %ecx,%edx
  800579:	f7 da                	neg    %edx
  80057b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  80057f:	0f 45 c2             	cmovne %edx,%eax
}
  800582:	83 c4 04             	add    $0x4,%esp
  800585:	5b                   	pop    %ebx
  800586:	5e                   	pop    %esi
  800587:	5f                   	pop    %edi
  800588:	5d                   	pop    %ebp
  800589:	c3                   	ret    
	...

0080058c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  80058c:	55                   	push   %ebp
  80058d:	89 e5                	mov    %esp,%ebp
  80058f:	83 ec 0c             	sub    $0xc,%esp
  800592:	89 1c 24             	mov    %ebx,(%esp)
  800595:	89 74 24 04          	mov    %esi,0x4(%esp)
  800599:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80059d:	ba 00 00 00 00       	mov    $0x0,%edx
  8005a2:	b8 01 00 00 00       	mov    $0x1,%eax
  8005a7:	89 d1                	mov    %edx,%ecx
  8005a9:	89 d3                	mov    %edx,%ebx
  8005ab:	89 d7                	mov    %edx,%edi
  8005ad:	89 d6                	mov    %edx,%esi
  8005af:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  8005b1:	8b 1c 24             	mov    (%esp),%ebx
  8005b4:	8b 74 24 04          	mov    0x4(%esp),%esi
  8005b8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8005bc:	89 ec                	mov    %ebp,%esp
  8005be:	5d                   	pop    %ebp
  8005bf:	c3                   	ret    

008005c0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  8005c0:	55                   	push   %ebp
  8005c1:	89 e5                	mov    %esp,%ebp
  8005c3:	83 ec 0c             	sub    $0xc,%esp
  8005c6:	89 1c 24             	mov    %ebx,(%esp)
  8005c9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005cd:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8005d1:	b8 00 00 00 00       	mov    $0x0,%eax
  8005d6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8005d9:	8b 55 08             	mov    0x8(%ebp),%edx
  8005dc:	89 c3                	mov    %eax,%ebx
  8005de:	89 c7                	mov    %eax,%edi
  8005e0:	89 c6                	mov    %eax,%esi
  8005e2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  8005e4:	8b 1c 24             	mov    (%esp),%ebx
  8005e7:	8b 74 24 04          	mov    0x4(%esp),%esi
  8005eb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8005ef:	89 ec                	mov    %ebp,%esp
  8005f1:	5d                   	pop    %ebp
  8005f2:	c3                   	ret    

008005f3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  8005f3:	55                   	push   %ebp
  8005f4:	89 e5                	mov    %esp,%ebp
  8005f6:	83 ec 0c             	sub    $0xc,%esp
  8005f9:	89 1c 24             	mov    %ebx,(%esp)
  8005fc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800600:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800604:	bb 00 00 00 00       	mov    $0x0,%ebx
  800609:	b8 10 00 00 00       	mov    $0x10,%eax
  80060e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800611:	8b 55 08             	mov    0x8(%ebp),%edx
  800614:	89 df                	mov    %ebx,%edi
  800616:	89 de                	mov    %ebx,%esi
  800618:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  80061a:	8b 1c 24             	mov    (%esp),%ebx
  80061d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800621:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800625:	89 ec                	mov    %ebp,%esp
  800627:	5d                   	pop    %ebp
  800628:	c3                   	ret    

00800629 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800629:	55                   	push   %ebp
  80062a:	89 e5                	mov    %esp,%ebp
  80062c:	83 ec 0c             	sub    $0xc,%esp
  80062f:	89 1c 24             	mov    %ebx,(%esp)
  800632:	89 74 24 04          	mov    %esi,0x4(%esp)
  800636:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80063a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80063f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800644:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800647:	8b 55 08             	mov    0x8(%ebp),%edx
  80064a:	89 df                	mov    %ebx,%edi
  80064c:	89 de                	mov    %ebx,%esi
  80064e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800650:	8b 1c 24             	mov    (%esp),%ebx
  800653:	8b 74 24 04          	mov    0x4(%esp),%esi
  800657:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80065b:	89 ec                	mov    %ebp,%esp
  80065d:	5d                   	pop    %ebp
  80065e:	c3                   	ret    

0080065f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80065f:	55                   	push   %ebp
  800660:	89 e5                	mov    %esp,%ebp
  800662:	83 ec 0c             	sub    $0xc,%esp
  800665:	89 1c 24             	mov    %ebx,(%esp)
  800668:	89 74 24 04          	mov    %esi,0x4(%esp)
  80066c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800670:	ba 00 00 00 00       	mov    $0x0,%edx
  800675:	b8 0e 00 00 00       	mov    $0xe,%eax
  80067a:	89 d1                	mov    %edx,%ecx
  80067c:	89 d3                	mov    %edx,%ebx
  80067e:	89 d7                	mov    %edx,%edi
  800680:	89 d6                	mov    %edx,%esi
  800682:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800684:	8b 1c 24             	mov    (%esp),%ebx
  800687:	8b 74 24 04          	mov    0x4(%esp),%esi
  80068b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80068f:	89 ec                	mov    %ebp,%esp
  800691:	5d                   	pop    %ebp
  800692:	c3                   	ret    

00800693 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800693:	55                   	push   %ebp
  800694:	89 e5                	mov    %esp,%ebp
  800696:	83 ec 38             	sub    $0x38,%esp
  800699:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80069c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80069f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8006a2:	b9 00 00 00 00       	mov    $0x0,%ecx
  8006a7:	b8 0d 00 00 00       	mov    $0xd,%eax
  8006ac:	8b 55 08             	mov    0x8(%ebp),%edx
  8006af:	89 cb                	mov    %ecx,%ebx
  8006b1:	89 cf                	mov    %ecx,%edi
  8006b3:	89 ce                	mov    %ecx,%esi
  8006b5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8006b7:	85 c0                	test   %eax,%eax
  8006b9:	7e 28                	jle    8006e3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8006bb:	89 44 24 10          	mov    %eax,0x10(%esp)
  8006bf:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  8006c6:	00 
  8006c7:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  8006ce:	00 
  8006cf:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8006d6:	00 
  8006d7:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  8006de:	e8 01 17 00 00       	call   801de4 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  8006e3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8006e6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8006e9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8006ec:	89 ec                	mov    %ebp,%esp
  8006ee:	5d                   	pop    %ebp
  8006ef:	c3                   	ret    

008006f0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  8006f0:	55                   	push   %ebp
  8006f1:	89 e5                	mov    %esp,%ebp
  8006f3:	83 ec 38             	sub    $0x38,%esp
  8006f6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8006f9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8006fc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8006ff:	be 00 00 00 00       	mov    $0x0,%esi
  800704:	b8 0c 00 00 00       	mov    $0xc,%eax
  800709:	8b 7d 14             	mov    0x14(%ebp),%edi
  80070c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80070f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800712:	8b 55 08             	mov    0x8(%ebp),%edx
  800715:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800717:	85 c0                	test   %eax,%eax
  800719:	7e 28                	jle    800743 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80071b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80071f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800726:	00 
  800727:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  80072e:	00 
  80072f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800736:	00 
  800737:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  80073e:	e8 a1 16 00 00       	call   801de4 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800743:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800746:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800749:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80074c:	89 ec                	mov    %ebp,%esp
  80074e:	5d                   	pop    %ebp
  80074f:	c3                   	ret    

00800750 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800750:	55                   	push   %ebp
  800751:	89 e5                	mov    %esp,%ebp
  800753:	83 ec 38             	sub    $0x38,%esp
  800756:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800759:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80075c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80075f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800764:	b8 0a 00 00 00       	mov    $0xa,%eax
  800769:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80076c:	8b 55 08             	mov    0x8(%ebp),%edx
  80076f:	89 df                	mov    %ebx,%edi
  800771:	89 de                	mov    %ebx,%esi
  800773:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800775:	85 c0                	test   %eax,%eax
  800777:	7e 28                	jle    8007a1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800779:	89 44 24 10          	mov    %eax,0x10(%esp)
  80077d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800784:	00 
  800785:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  80078c:	00 
  80078d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800794:	00 
  800795:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  80079c:	e8 43 16 00 00       	call   801de4 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8007a1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8007a4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8007a7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8007aa:	89 ec                	mov    %ebp,%esp
  8007ac:	5d                   	pop    %ebp
  8007ad:	c3                   	ret    

008007ae <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8007ae:	55                   	push   %ebp
  8007af:	89 e5                	mov    %esp,%ebp
  8007b1:	83 ec 38             	sub    $0x38,%esp
  8007b4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8007b7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8007ba:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8007bd:	bb 00 00 00 00       	mov    $0x0,%ebx
  8007c2:	b8 09 00 00 00       	mov    $0x9,%eax
  8007c7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8007ca:	8b 55 08             	mov    0x8(%ebp),%edx
  8007cd:	89 df                	mov    %ebx,%edi
  8007cf:	89 de                	mov    %ebx,%esi
  8007d1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8007d3:	85 c0                	test   %eax,%eax
  8007d5:	7e 28                	jle    8007ff <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8007d7:	89 44 24 10          	mov    %eax,0x10(%esp)
  8007db:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  8007e2:	00 
  8007e3:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  8007ea:	00 
  8007eb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8007f2:	00 
  8007f3:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  8007fa:	e8 e5 15 00 00       	call   801de4 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  8007ff:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800802:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800805:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800808:	89 ec                	mov    %ebp,%esp
  80080a:	5d                   	pop    %ebp
  80080b:	c3                   	ret    

0080080c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80080c:	55                   	push   %ebp
  80080d:	89 e5                	mov    %esp,%ebp
  80080f:	83 ec 38             	sub    $0x38,%esp
  800812:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800815:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800818:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80081b:	bb 00 00 00 00       	mov    $0x0,%ebx
  800820:	b8 08 00 00 00       	mov    $0x8,%eax
  800825:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800828:	8b 55 08             	mov    0x8(%ebp),%edx
  80082b:	89 df                	mov    %ebx,%edi
  80082d:	89 de                	mov    %ebx,%esi
  80082f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800831:	85 c0                	test   %eax,%eax
  800833:	7e 28                	jle    80085d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800835:	89 44 24 10          	mov    %eax,0x10(%esp)
  800839:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  800840:	00 
  800841:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  800848:	00 
  800849:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800850:	00 
  800851:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  800858:	e8 87 15 00 00       	call   801de4 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80085d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800860:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800863:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800866:	89 ec                	mov    %ebp,%esp
  800868:	5d                   	pop    %ebp
  800869:	c3                   	ret    

0080086a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80086a:	55                   	push   %ebp
  80086b:	89 e5                	mov    %esp,%ebp
  80086d:	83 ec 38             	sub    $0x38,%esp
  800870:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800873:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800876:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800879:	bb 00 00 00 00       	mov    $0x0,%ebx
  80087e:	b8 06 00 00 00       	mov    $0x6,%eax
  800883:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800886:	8b 55 08             	mov    0x8(%ebp),%edx
  800889:	89 df                	mov    %ebx,%edi
  80088b:	89 de                	mov    %ebx,%esi
  80088d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80088f:	85 c0                	test   %eax,%eax
  800891:	7e 28                	jle    8008bb <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800893:	89 44 24 10          	mov    %eax,0x10(%esp)
  800897:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80089e:	00 
  80089f:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  8008a6:	00 
  8008a7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8008ae:	00 
  8008af:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  8008b6:	e8 29 15 00 00       	call   801de4 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8008bb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8008be:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8008c1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8008c4:	89 ec                	mov    %ebp,%esp
  8008c6:	5d                   	pop    %ebp
  8008c7:	c3                   	ret    

008008c8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8008c8:	55                   	push   %ebp
  8008c9:	89 e5                	mov    %esp,%ebp
  8008cb:	83 ec 38             	sub    $0x38,%esp
  8008ce:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8008d1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8008d4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8008d7:	b8 05 00 00 00       	mov    $0x5,%eax
  8008dc:	8b 75 18             	mov    0x18(%ebp),%esi
  8008df:	8b 7d 14             	mov    0x14(%ebp),%edi
  8008e2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8008e5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8008e8:	8b 55 08             	mov    0x8(%ebp),%edx
  8008eb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8008ed:	85 c0                	test   %eax,%eax
  8008ef:	7e 28                	jle    800919 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8008f1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8008f5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8008fc:	00 
  8008fd:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  800904:	00 
  800905:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80090c:	00 
  80090d:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  800914:	e8 cb 14 00 00       	call   801de4 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  800919:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80091c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80091f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800922:	89 ec                	mov    %ebp,%esp
  800924:	5d                   	pop    %ebp
  800925:	c3                   	ret    

00800926 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  800926:	55                   	push   %ebp
  800927:	89 e5                	mov    %esp,%ebp
  800929:	83 ec 38             	sub    $0x38,%esp
  80092c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80092f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800932:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800935:	be 00 00 00 00       	mov    $0x0,%esi
  80093a:	b8 04 00 00 00       	mov    $0x4,%eax
  80093f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800942:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800945:	8b 55 08             	mov    0x8(%ebp),%edx
  800948:	89 f7                	mov    %esi,%edi
  80094a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80094c:	85 c0                	test   %eax,%eax
  80094e:	7e 28                	jle    800978 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  800950:	89 44 24 10          	mov    %eax,0x10(%esp)
  800954:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80095b:	00 
  80095c:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  800963:	00 
  800964:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80096b:	00 
  80096c:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  800973:	e8 6c 14 00 00       	call   801de4 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  800978:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80097b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80097e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800981:	89 ec                	mov    %ebp,%esp
  800983:	5d                   	pop    %ebp
  800984:	c3                   	ret    

00800985 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  800985:	55                   	push   %ebp
  800986:	89 e5                	mov    %esp,%ebp
  800988:	83 ec 0c             	sub    $0xc,%esp
  80098b:	89 1c 24             	mov    %ebx,(%esp)
  80098e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800992:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800996:	ba 00 00 00 00       	mov    $0x0,%edx
  80099b:	b8 0b 00 00 00       	mov    $0xb,%eax
  8009a0:	89 d1                	mov    %edx,%ecx
  8009a2:	89 d3                	mov    %edx,%ebx
  8009a4:	89 d7                	mov    %edx,%edi
  8009a6:	89 d6                	mov    %edx,%esi
  8009a8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8009aa:	8b 1c 24             	mov    (%esp),%ebx
  8009ad:	8b 74 24 04          	mov    0x4(%esp),%esi
  8009b1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8009b5:	89 ec                	mov    %ebp,%esp
  8009b7:	5d                   	pop    %ebp
  8009b8:	c3                   	ret    

008009b9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8009b9:	55                   	push   %ebp
  8009ba:	89 e5                	mov    %esp,%ebp
  8009bc:	83 ec 0c             	sub    $0xc,%esp
  8009bf:	89 1c 24             	mov    %ebx,(%esp)
  8009c2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009c6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8009ca:	ba 00 00 00 00       	mov    $0x0,%edx
  8009cf:	b8 02 00 00 00       	mov    $0x2,%eax
  8009d4:	89 d1                	mov    %edx,%ecx
  8009d6:	89 d3                	mov    %edx,%ebx
  8009d8:	89 d7                	mov    %edx,%edi
  8009da:	89 d6                	mov    %edx,%esi
  8009dc:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8009de:	8b 1c 24             	mov    (%esp),%ebx
  8009e1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8009e5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8009e9:	89 ec                	mov    %ebp,%esp
  8009eb:	5d                   	pop    %ebp
  8009ec:	c3                   	ret    

008009ed <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8009ed:	55                   	push   %ebp
  8009ee:	89 e5                	mov    %esp,%ebp
  8009f0:	83 ec 38             	sub    $0x38,%esp
  8009f3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8009f6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8009f9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8009fc:	b9 00 00 00 00       	mov    $0x0,%ecx
  800a01:	b8 03 00 00 00       	mov    $0x3,%eax
  800a06:	8b 55 08             	mov    0x8(%ebp),%edx
  800a09:	89 cb                	mov    %ecx,%ebx
  800a0b:	89 cf                	mov    %ecx,%edi
  800a0d:	89 ce                	mov    %ecx,%esi
  800a0f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800a11:	85 c0                	test   %eax,%eax
  800a13:	7e 28                	jle    800a3d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800a15:	89 44 24 10          	mov    %eax,0x10(%esp)
  800a19:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  800a20:	00 
  800a21:	c7 44 24 08 da 28 80 	movl   $0x8028da,0x8(%esp)
  800a28:	00 
  800a29:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800a30:	00 
  800a31:	c7 04 24 f7 28 80 00 	movl   $0x8028f7,(%esp)
  800a38:	e8 a7 13 00 00       	call   801de4 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  800a3d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800a40:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800a43:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800a46:	89 ec                	mov    %ebp,%esp
  800a48:	5d                   	pop    %ebp
  800a49:	c3                   	ret    
  800a4a:	00 00                	add    %al,(%eax)
  800a4c:	00 00                	add    %al,(%eax)
	...

00800a50 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  800a50:	55                   	push   %ebp
  800a51:	89 e5                	mov    %esp,%ebp
  800a53:	8b 45 08             	mov    0x8(%ebp),%eax
  800a56:	05 00 00 00 30       	add    $0x30000000,%eax
  800a5b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  800a5e:	5d                   	pop    %ebp
  800a5f:	c3                   	ret    

00800a60 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  800a60:	55                   	push   %ebp
  800a61:	89 e5                	mov    %esp,%ebp
  800a63:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  800a66:	8b 45 08             	mov    0x8(%ebp),%eax
  800a69:	89 04 24             	mov    %eax,(%esp)
  800a6c:	e8 df ff ff ff       	call   800a50 <fd2num>
  800a71:	05 20 00 0d 00       	add    $0xd0020,%eax
  800a76:	c1 e0 0c             	shl    $0xc,%eax
}
  800a79:	c9                   	leave  
  800a7a:	c3                   	ret    

00800a7b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  800a7b:	55                   	push   %ebp
  800a7c:	89 e5                	mov    %esp,%ebp
  800a7e:	57                   	push   %edi
  800a7f:	56                   	push   %esi
  800a80:	53                   	push   %ebx
  800a81:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  800a84:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  800a89:	a8 01                	test   $0x1,%al
  800a8b:	74 36                	je     800ac3 <fd_alloc+0x48>
  800a8d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  800a92:	a8 01                	test   $0x1,%al
  800a94:	74 2d                	je     800ac3 <fd_alloc+0x48>
  800a96:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  800a9b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  800aa0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  800aa5:	89 c3                	mov    %eax,%ebx
  800aa7:	89 c2                	mov    %eax,%edx
  800aa9:	c1 ea 16             	shr    $0x16,%edx
  800aac:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  800aaf:	f6 c2 01             	test   $0x1,%dl
  800ab2:	74 14                	je     800ac8 <fd_alloc+0x4d>
  800ab4:	89 c2                	mov    %eax,%edx
  800ab6:	c1 ea 0c             	shr    $0xc,%edx
  800ab9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  800abc:	f6 c2 01             	test   $0x1,%dl
  800abf:	75 10                	jne    800ad1 <fd_alloc+0x56>
  800ac1:	eb 05                	jmp    800ac8 <fd_alloc+0x4d>
  800ac3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  800ac8:	89 1f                	mov    %ebx,(%edi)
  800aca:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  800acf:	eb 17                	jmp    800ae8 <fd_alloc+0x6d>
  800ad1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  800ad6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  800adb:	75 c8                	jne    800aa5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  800add:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  800ae3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  800ae8:	5b                   	pop    %ebx
  800ae9:	5e                   	pop    %esi
  800aea:	5f                   	pop    %edi
  800aeb:	5d                   	pop    %ebp
  800aec:	c3                   	ret    

00800aed <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  800aed:	55                   	push   %ebp
  800aee:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  800af0:	8b 45 08             	mov    0x8(%ebp),%eax
  800af3:	83 f8 1f             	cmp    $0x1f,%eax
  800af6:	77 36                	ja     800b2e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  800af8:	05 00 00 0d 00       	add    $0xd0000,%eax
  800afd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  800b00:	89 c2                	mov    %eax,%edx
  800b02:	c1 ea 16             	shr    $0x16,%edx
  800b05:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  800b0c:	f6 c2 01             	test   $0x1,%dl
  800b0f:	74 1d                	je     800b2e <fd_lookup+0x41>
  800b11:	89 c2                	mov    %eax,%edx
  800b13:	c1 ea 0c             	shr    $0xc,%edx
  800b16:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  800b1d:	f6 c2 01             	test   $0x1,%dl
  800b20:	74 0c                	je     800b2e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  800b22:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b25:	89 02                	mov    %eax,(%edx)
  800b27:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  800b2c:	eb 05                	jmp    800b33 <fd_lookup+0x46>
  800b2e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  800b33:	5d                   	pop    %ebp
  800b34:	c3                   	ret    

00800b35 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  800b35:	55                   	push   %ebp
  800b36:	89 e5                	mov    %esp,%ebp
  800b38:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  800b3b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  800b3e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b42:	8b 45 08             	mov    0x8(%ebp),%eax
  800b45:	89 04 24             	mov    %eax,(%esp)
  800b48:	e8 a0 ff ff ff       	call   800aed <fd_lookup>
  800b4d:	85 c0                	test   %eax,%eax
  800b4f:	78 0e                	js     800b5f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  800b51:	8b 45 fc             	mov    -0x4(%ebp),%eax
  800b54:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b57:	89 50 04             	mov    %edx,0x4(%eax)
  800b5a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  800b5f:	c9                   	leave  
  800b60:	c3                   	ret    

00800b61 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  800b61:	55                   	push   %ebp
  800b62:	89 e5                	mov    %esp,%ebp
  800b64:	56                   	push   %esi
  800b65:	53                   	push   %ebx
  800b66:	83 ec 10             	sub    $0x10,%esp
  800b69:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800b6c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  800b6f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  800b74:	b8 04 60 80 00       	mov    $0x806004,%eax
  800b79:	39 0d 04 60 80 00    	cmp    %ecx,0x806004
  800b7f:	75 11                	jne    800b92 <dev_lookup+0x31>
  800b81:	eb 04                	jmp    800b87 <dev_lookup+0x26>
  800b83:	39 08                	cmp    %ecx,(%eax)
  800b85:	75 10                	jne    800b97 <dev_lookup+0x36>
			*dev = devtab[i];
  800b87:	89 03                	mov    %eax,(%ebx)
  800b89:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  800b8e:	66 90                	xchg   %ax,%ax
  800b90:	eb 36                	jmp    800bc8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  800b92:	be 84 29 80 00       	mov    $0x802984,%esi
  800b97:	83 c2 01             	add    $0x1,%edx
  800b9a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  800b9d:	85 c0                	test   %eax,%eax
  800b9f:	75 e2                	jne    800b83 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  800ba1:	a1 74 60 80 00       	mov    0x806074,%eax
  800ba6:	8b 40 4c             	mov    0x4c(%eax),%eax
  800ba9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  800bad:	89 44 24 04          	mov    %eax,0x4(%esp)
  800bb1:	c7 04 24 08 29 80 00 	movl   $0x802908,(%esp)
  800bb8:	e8 ec 12 00 00       	call   801ea9 <cprintf>
	*dev = 0;
  800bbd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  800bc3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  800bc8:	83 c4 10             	add    $0x10,%esp
  800bcb:	5b                   	pop    %ebx
  800bcc:	5e                   	pop    %esi
  800bcd:	5d                   	pop    %ebp
  800bce:	c3                   	ret    

00800bcf <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  800bcf:	55                   	push   %ebp
  800bd0:	89 e5                	mov    %esp,%ebp
  800bd2:	53                   	push   %ebx
  800bd3:	83 ec 24             	sub    $0x24,%esp
  800bd6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  800bd9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  800bdc:	89 44 24 04          	mov    %eax,0x4(%esp)
  800be0:	8b 45 08             	mov    0x8(%ebp),%eax
  800be3:	89 04 24             	mov    %eax,(%esp)
  800be6:	e8 02 ff ff ff       	call   800aed <fd_lookup>
  800beb:	85 c0                	test   %eax,%eax
  800bed:	78 53                	js     800c42 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  800bef:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800bf2:	89 44 24 04          	mov    %eax,0x4(%esp)
  800bf6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800bf9:	8b 00                	mov    (%eax),%eax
  800bfb:	89 04 24             	mov    %eax,(%esp)
  800bfe:	e8 5e ff ff ff       	call   800b61 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  800c03:	85 c0                	test   %eax,%eax
  800c05:	78 3b                	js     800c42 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  800c07:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  800c0c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  800c0f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  800c13:	74 2d                	je     800c42 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  800c15:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  800c18:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  800c1f:	00 00 00 
	stat->st_isdir = 0;
  800c22:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  800c29:	00 00 00 
	stat->st_dev = dev;
  800c2c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800c2f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  800c35:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800c39:	8b 55 f0             	mov    -0x10(%ebp),%edx
  800c3c:	89 14 24             	mov    %edx,(%esp)
  800c3f:	ff 50 14             	call   *0x14(%eax)
}
  800c42:	83 c4 24             	add    $0x24,%esp
  800c45:	5b                   	pop    %ebx
  800c46:	5d                   	pop    %ebp
  800c47:	c3                   	ret    

00800c48 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  800c48:	55                   	push   %ebp
  800c49:	89 e5                	mov    %esp,%ebp
  800c4b:	53                   	push   %ebx
  800c4c:	83 ec 24             	sub    $0x24,%esp
  800c4f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  800c52:	8d 45 f0             	lea    -0x10(%ebp),%eax
  800c55:	89 44 24 04          	mov    %eax,0x4(%esp)
  800c59:	89 1c 24             	mov    %ebx,(%esp)
  800c5c:	e8 8c fe ff ff       	call   800aed <fd_lookup>
  800c61:	85 c0                	test   %eax,%eax
  800c63:	78 5f                	js     800cc4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  800c65:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800c68:	89 44 24 04          	mov    %eax,0x4(%esp)
  800c6c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800c6f:	8b 00                	mov    (%eax),%eax
  800c71:	89 04 24             	mov    %eax,(%esp)
  800c74:	e8 e8 fe ff ff       	call   800b61 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  800c79:	85 c0                	test   %eax,%eax
  800c7b:	78 47                	js     800cc4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  800c7d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  800c80:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  800c84:	75 23                	jne    800ca9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  800c86:	a1 74 60 80 00       	mov    0x806074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  800c8b:	8b 40 4c             	mov    0x4c(%eax),%eax
  800c8e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800c92:	89 44 24 04          	mov    %eax,0x4(%esp)
  800c96:	c7 04 24 28 29 80 00 	movl   $0x802928,(%esp)
  800c9d:	e8 07 12 00 00       	call   801ea9 <cprintf>
  800ca2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  800ca7:	eb 1b                	jmp    800cc4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  800ca9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800cac:	8b 48 18             	mov    0x18(%eax),%ecx
  800caf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  800cb4:	85 c9                	test   %ecx,%ecx
  800cb6:	74 0c                	je     800cc4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  800cb8:	8b 45 0c             	mov    0xc(%ebp),%eax
  800cbb:	89 44 24 04          	mov    %eax,0x4(%esp)
  800cbf:	89 14 24             	mov    %edx,(%esp)
  800cc2:	ff d1                	call   *%ecx
}
  800cc4:	83 c4 24             	add    $0x24,%esp
  800cc7:	5b                   	pop    %ebx
  800cc8:	5d                   	pop    %ebp
  800cc9:	c3                   	ret    

00800cca <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  800cca:	55                   	push   %ebp
  800ccb:	89 e5                	mov    %esp,%ebp
  800ccd:	53                   	push   %ebx
  800cce:	83 ec 24             	sub    $0x24,%esp
  800cd1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  800cd4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  800cd7:	89 44 24 04          	mov    %eax,0x4(%esp)
  800cdb:	89 1c 24             	mov    %ebx,(%esp)
  800cde:	e8 0a fe ff ff       	call   800aed <fd_lookup>
  800ce3:	85 c0                	test   %eax,%eax
  800ce5:	78 66                	js     800d4d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  800ce7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800cea:	89 44 24 04          	mov    %eax,0x4(%esp)
  800cee:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800cf1:	8b 00                	mov    (%eax),%eax
  800cf3:	89 04 24             	mov    %eax,(%esp)
  800cf6:	e8 66 fe ff ff       	call   800b61 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  800cfb:	85 c0                	test   %eax,%eax
  800cfd:	78 4e                	js     800d4d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  800cff:	8b 55 f0             	mov    -0x10(%ebp),%edx
  800d02:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  800d06:	75 23                	jne    800d2b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  800d08:	a1 74 60 80 00       	mov    0x806074,%eax
  800d0d:	8b 40 4c             	mov    0x4c(%eax),%eax
  800d10:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800d14:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d18:	c7 04 24 49 29 80 00 	movl   $0x802949,(%esp)
  800d1f:	e8 85 11 00 00       	call   801ea9 <cprintf>
  800d24:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  800d29:	eb 22                	jmp    800d4d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  800d2b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800d2e:	8b 48 0c             	mov    0xc(%eax),%ecx
  800d31:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  800d36:	85 c9                	test   %ecx,%ecx
  800d38:	74 13                	je     800d4d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  800d3a:	8b 45 10             	mov    0x10(%ebp),%eax
  800d3d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d41:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d44:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d48:	89 14 24             	mov    %edx,(%esp)
  800d4b:	ff d1                	call   *%ecx
}
  800d4d:	83 c4 24             	add    $0x24,%esp
  800d50:	5b                   	pop    %ebx
  800d51:	5d                   	pop    %ebp
  800d52:	c3                   	ret    

00800d53 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  800d53:	55                   	push   %ebp
  800d54:	89 e5                	mov    %esp,%ebp
  800d56:	57                   	push   %edi
  800d57:	56                   	push   %esi
  800d58:	53                   	push   %ebx
  800d59:	83 ec 2c             	sub    $0x2c,%esp
  800d5c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800d5f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  800d62:	8d 45 e0             	lea    -0x20(%ebp),%eax
  800d65:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d69:	89 1c 24             	mov    %ebx,(%esp)
  800d6c:	e8 7c fd ff ff       	call   800aed <fd_lookup>
  800d71:	85 c0                	test   %eax,%eax
  800d73:	0f 88 b0 00 00 00    	js     800e29 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  800d79:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  800d7c:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d80:	8b 45 e0             	mov    -0x20(%ebp),%eax
  800d83:	8b 00                	mov    (%eax),%eax
  800d85:	89 04 24             	mov    %eax,(%esp)
  800d88:	e8 d4 fd ff ff       	call   800b61 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  800d8d:	85 c0                	test   %eax,%eax
  800d8f:	0f 88 94 00 00 00    	js     800e29 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  800d95:	8b 45 e0             	mov    -0x20(%ebp),%eax
  800d98:	8b 40 08             	mov    0x8(%eax),%eax
  800d9b:	83 e0 03             	and    $0x3,%eax
  800d9e:	83 f8 01             	cmp    $0x1,%eax
  800da1:	75 23                	jne    800dc6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  800da3:	a1 74 60 80 00       	mov    0x806074,%eax
  800da8:	8b 40 4c             	mov    0x4c(%eax),%eax
  800dab:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800daf:	89 44 24 04          	mov    %eax,0x4(%esp)
  800db3:	c7 04 24 66 29 80 00 	movl   $0x802966,(%esp)
  800dba:	e8 ea 10 00 00       	call   801ea9 <cprintf>
  800dbf:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  800dc4:	eb 63                	jmp    800e29 <read+0xd6>
	}
	if (!dev->dev_read)
  800dc6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  800dcb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800dce:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  800dd2:	74 55                	je     800e29 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  800dd4:	ba 00 00 00 00       	mov    $0x0,%edx
  800dd9:	bb 00 00 00 00       	mov    $0x0,%ebx
  800dde:	b8 00 00 00 00       	mov    $0x0,%eax
  800de3:	85 f6                	test   %esi,%esi
  800de5:	74 42                	je     800e29 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  800de7:	bf 00 10 00 00       	mov    $0x1000,%edi
  800dec:	89 f0                	mov    %esi,%eax
  800dee:	29 d0                	sub    %edx,%eax
  800df0:	89 c1                	mov    %eax,%ecx
  800df2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  800df8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  800dfd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  800e00:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  800e04:	03 55 0c             	add    0xc(%ebp),%edx
  800e07:	89 54 24 04          	mov    %edx,0x4(%esp)
  800e0b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  800e0e:	89 04 24             	mov    %eax,(%esp)
  800e11:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800e14:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  800e17:	85 c0                	test   %eax,%eax
  800e19:	78 0e                	js     800e29 <read+0xd6>
			return m;
		if (m == 0)
  800e1b:	85 c0                	test   %eax,%eax
  800e1d:	74 08                	je     800e27 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  800e1f:	01 c3                	add    %eax,%ebx
  800e21:	89 da                	mov    %ebx,%edx
  800e23:	39 f3                	cmp    %esi,%ebx
  800e25:	72 c5                	jb     800dec <read+0x99>
  800e27:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  800e29:	83 c4 2c             	add    $0x2c,%esp
  800e2c:	5b                   	pop    %ebx
  800e2d:	5e                   	pop    %esi
  800e2e:	5f                   	pop    %edi
  800e2f:	5d                   	pop    %ebp
  800e30:	c3                   	ret    

00800e31 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  800e31:	55                   	push   %ebp
  800e32:	89 e5                	mov    %esp,%ebp
  800e34:	57                   	push   %edi
  800e35:	56                   	push   %esi
  800e36:	53                   	push   %ebx
  800e37:	83 ec 1c             	sub    $0x1c,%esp
  800e3a:	8b 7d 08             	mov    0x8(%ebp),%edi
  800e3d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  800e40:	ba 00 00 00 00       	mov    $0x0,%edx
  800e45:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e4a:	b8 00 00 00 00       	mov    $0x0,%eax
  800e4f:	85 f6                	test   %esi,%esi
  800e51:	74 29                	je     800e7c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  800e53:	89 f0                	mov    %esi,%eax
  800e55:	29 d0                	sub    %edx,%eax
  800e57:	89 44 24 08          	mov    %eax,0x8(%esp)
  800e5b:	03 55 0c             	add    0xc(%ebp),%edx
  800e5e:	89 54 24 04          	mov    %edx,0x4(%esp)
  800e62:	89 3c 24             	mov    %edi,(%esp)
  800e65:	e8 e9 fe ff ff       	call   800d53 <read>
		if (m < 0)
  800e6a:	85 c0                	test   %eax,%eax
  800e6c:	78 0e                	js     800e7c <readn+0x4b>
			return m;
		if (m == 0)
  800e6e:	85 c0                	test   %eax,%eax
  800e70:	74 08                	je     800e7a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  800e72:	01 c3                	add    %eax,%ebx
  800e74:	89 da                	mov    %ebx,%edx
  800e76:	39 f3                	cmp    %esi,%ebx
  800e78:	72 d9                	jb     800e53 <readn+0x22>
  800e7a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  800e7c:	83 c4 1c             	add    $0x1c,%esp
  800e7f:	5b                   	pop    %ebx
  800e80:	5e                   	pop    %esi
  800e81:	5f                   	pop    %edi
  800e82:	5d                   	pop    %ebp
  800e83:	c3                   	ret    

00800e84 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  800e84:	55                   	push   %ebp
  800e85:	89 e5                	mov    %esp,%ebp
  800e87:	83 ec 28             	sub    $0x28,%esp
  800e8a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800e8d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800e90:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  800e93:	89 34 24             	mov    %esi,(%esp)
  800e96:	e8 b5 fb ff ff       	call   800a50 <fd2num>
  800e9b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  800e9e:	89 54 24 04          	mov    %edx,0x4(%esp)
  800ea2:	89 04 24             	mov    %eax,(%esp)
  800ea5:	e8 43 fc ff ff       	call   800aed <fd_lookup>
  800eaa:	89 c3                	mov    %eax,%ebx
  800eac:	85 c0                	test   %eax,%eax
  800eae:	78 05                	js     800eb5 <fd_close+0x31>
  800eb0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  800eb3:	74 0e                	je     800ec3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  800eb5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800eb9:	b8 00 00 00 00       	mov    $0x0,%eax
  800ebe:	0f 44 d8             	cmove  %eax,%ebx
  800ec1:	eb 3d                	jmp    800f00 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  800ec3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  800ec6:	89 44 24 04          	mov    %eax,0x4(%esp)
  800eca:	8b 06                	mov    (%esi),%eax
  800ecc:	89 04 24             	mov    %eax,(%esp)
  800ecf:	e8 8d fc ff ff       	call   800b61 <dev_lookup>
  800ed4:	89 c3                	mov    %eax,%ebx
  800ed6:	85 c0                	test   %eax,%eax
  800ed8:	78 16                	js     800ef0 <fd_close+0x6c>
		if (dev->dev_close)
  800eda:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800edd:	8b 40 10             	mov    0x10(%eax),%eax
  800ee0:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ee5:	85 c0                	test   %eax,%eax
  800ee7:	74 07                	je     800ef0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  800ee9:	89 34 24             	mov    %esi,(%esp)
  800eec:	ff d0                	call   *%eax
  800eee:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  800ef0:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ef4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800efb:	e8 6a f9 ff ff       	call   80086a <sys_page_unmap>
	return r;
}
  800f00:	89 d8                	mov    %ebx,%eax
  800f02:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800f05:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800f08:	89 ec                	mov    %ebp,%esp
  800f0a:	5d                   	pop    %ebp
  800f0b:	c3                   	ret    

00800f0c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  800f0c:	55                   	push   %ebp
  800f0d:	89 e5                	mov    %esp,%ebp
  800f0f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  800f12:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800f15:	89 44 24 04          	mov    %eax,0x4(%esp)
  800f19:	8b 45 08             	mov    0x8(%ebp),%eax
  800f1c:	89 04 24             	mov    %eax,(%esp)
  800f1f:	e8 c9 fb ff ff       	call   800aed <fd_lookup>
  800f24:	85 c0                	test   %eax,%eax
  800f26:	78 13                	js     800f3b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  800f28:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  800f2f:	00 
  800f30:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800f33:	89 04 24             	mov    %eax,(%esp)
  800f36:	e8 49 ff ff ff       	call   800e84 <fd_close>
}
  800f3b:	c9                   	leave  
  800f3c:	c3                   	ret    

00800f3d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  800f3d:	55                   	push   %ebp
  800f3e:	89 e5                	mov    %esp,%ebp
  800f40:	83 ec 18             	sub    $0x18,%esp
  800f43:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800f46:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  800f49:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800f50:	00 
  800f51:	8b 45 08             	mov    0x8(%ebp),%eax
  800f54:	89 04 24             	mov    %eax,(%esp)
  800f57:	e8 80 03 00 00       	call   8012dc <open>
  800f5c:	89 c3                	mov    %eax,%ebx
  800f5e:	85 c0                	test   %eax,%eax
  800f60:	78 1b                	js     800f7d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  800f62:	8b 45 0c             	mov    0xc(%ebp),%eax
  800f65:	89 44 24 04          	mov    %eax,0x4(%esp)
  800f69:	89 1c 24             	mov    %ebx,(%esp)
  800f6c:	e8 5e fc ff ff       	call   800bcf <fstat>
  800f71:	89 c6                	mov    %eax,%esi
	close(fd);
  800f73:	89 1c 24             	mov    %ebx,(%esp)
  800f76:	e8 91 ff ff ff       	call   800f0c <close>
  800f7b:	89 f3                	mov    %esi,%ebx
	return r;
}
  800f7d:	89 d8                	mov    %ebx,%eax
  800f7f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800f82:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800f85:	89 ec                	mov    %ebp,%esp
  800f87:	5d                   	pop    %ebp
  800f88:	c3                   	ret    

00800f89 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  800f89:	55                   	push   %ebp
  800f8a:	89 e5                	mov    %esp,%ebp
  800f8c:	53                   	push   %ebx
  800f8d:	83 ec 14             	sub    $0x14,%esp
  800f90:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  800f95:	89 1c 24             	mov    %ebx,(%esp)
  800f98:	e8 6f ff ff ff       	call   800f0c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  800f9d:	83 c3 01             	add    $0x1,%ebx
  800fa0:	83 fb 20             	cmp    $0x20,%ebx
  800fa3:	75 f0                	jne    800f95 <close_all+0xc>
		close(i);
}
  800fa5:	83 c4 14             	add    $0x14,%esp
  800fa8:	5b                   	pop    %ebx
  800fa9:	5d                   	pop    %ebp
  800faa:	c3                   	ret    

00800fab <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  800fab:	55                   	push   %ebp
  800fac:	89 e5                	mov    %esp,%ebp
  800fae:	83 ec 58             	sub    $0x58,%esp
  800fb1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fb4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fb7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  800fba:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  800fbd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  800fc0:	89 44 24 04          	mov    %eax,0x4(%esp)
  800fc4:	8b 45 08             	mov    0x8(%ebp),%eax
  800fc7:	89 04 24             	mov    %eax,(%esp)
  800fca:	e8 1e fb ff ff       	call   800aed <fd_lookup>
  800fcf:	89 c3                	mov    %eax,%ebx
  800fd1:	85 c0                	test   %eax,%eax
  800fd3:	0f 88 e0 00 00 00    	js     8010b9 <dup+0x10e>
		return r;
	close(newfdnum);
  800fd9:	89 3c 24             	mov    %edi,(%esp)
  800fdc:	e8 2b ff ff ff       	call   800f0c <close>

	newfd = INDEX2FD(newfdnum);
  800fe1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  800fe7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  800fea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800fed:	89 04 24             	mov    %eax,(%esp)
  800ff0:	e8 6b fa ff ff       	call   800a60 <fd2data>
  800ff5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  800ff7:	89 34 24             	mov    %esi,(%esp)
  800ffa:	e8 61 fa ff ff       	call   800a60 <fd2data>
  800fff:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801002:	89 da                	mov    %ebx,%edx
  801004:	89 d8                	mov    %ebx,%eax
  801006:	c1 e8 16             	shr    $0x16,%eax
  801009:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801010:	a8 01                	test   $0x1,%al
  801012:	74 43                	je     801057 <dup+0xac>
  801014:	c1 ea 0c             	shr    $0xc,%edx
  801017:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80101e:	a8 01                	test   $0x1,%al
  801020:	74 35                	je     801057 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801022:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801029:	25 07 0e 00 00       	and    $0xe07,%eax
  80102e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801032:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801035:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801039:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801040:	00 
  801041:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801045:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80104c:	e8 77 f8 ff ff       	call   8008c8 <sys_page_map>
  801051:	89 c3                	mov    %eax,%ebx
  801053:	85 c0                	test   %eax,%eax
  801055:	78 3f                	js     801096 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801057:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80105a:	89 c2                	mov    %eax,%edx
  80105c:	c1 ea 0c             	shr    $0xc,%edx
  80105f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801066:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80106c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801070:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801074:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80107b:	00 
  80107c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801080:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801087:	e8 3c f8 ff ff       	call   8008c8 <sys_page_map>
  80108c:	89 c3                	mov    %eax,%ebx
  80108e:	85 c0                	test   %eax,%eax
  801090:	78 04                	js     801096 <dup+0xeb>
  801092:	89 fb                	mov    %edi,%ebx
  801094:	eb 23                	jmp    8010b9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801096:	89 74 24 04          	mov    %esi,0x4(%esp)
  80109a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8010a1:	e8 c4 f7 ff ff       	call   80086a <sys_page_unmap>
	sys_page_unmap(0, nva);
  8010a6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8010a9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8010ad:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8010b4:	e8 b1 f7 ff ff       	call   80086a <sys_page_unmap>
	return r;
}
  8010b9:	89 d8                	mov    %ebx,%eax
  8010bb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010be:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010c1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010c4:	89 ec                	mov    %ebp,%esp
  8010c6:	5d                   	pop    %ebp
  8010c7:	c3                   	ret    

008010c8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  8010c8:	55                   	push   %ebp
  8010c9:	89 e5                	mov    %esp,%ebp
  8010cb:	53                   	push   %ebx
  8010cc:	83 ec 14             	sub    $0x14,%esp
  8010cf:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  8010d1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  8010d7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8010de:	00 
  8010df:	c7 44 24 08 00 30 80 	movl   $0x803000,0x8(%esp)
  8010e6:	00 
  8010e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8010eb:	89 14 24             	mov    %edx,(%esp)
  8010ee:	e8 3d 14 00 00       	call   802530 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8010f3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8010fa:	00 
  8010fb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8010ff:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801106:	e8 97 14 00 00       	call   8025a2 <ipc_recv>
}
  80110b:	83 c4 14             	add    $0x14,%esp
  80110e:	5b                   	pop    %ebx
  80110f:	5d                   	pop    %ebp
  801110:	c3                   	ret    

00801111 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801111:	55                   	push   %ebp
  801112:	89 e5                	mov    %esp,%ebp
  801114:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801117:	8b 45 08             	mov    0x8(%ebp),%eax
  80111a:	8b 40 0c             	mov    0xc(%eax),%eax
  80111d:	a3 00 30 80 00       	mov    %eax,0x803000
	fsipcbuf.set_size.req_size = newsize;
  801122:	8b 45 0c             	mov    0xc(%ebp),%eax
  801125:	a3 04 30 80 00       	mov    %eax,0x803004
	return fsipc(FSREQ_SET_SIZE, NULL);
  80112a:	ba 00 00 00 00       	mov    $0x0,%edx
  80112f:	b8 02 00 00 00       	mov    $0x2,%eax
  801134:	e8 8f ff ff ff       	call   8010c8 <fsipc>
}
  801139:	c9                   	leave  
  80113a:	c3                   	ret    

0080113b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  80113b:	55                   	push   %ebp
  80113c:	89 e5                	mov    %esp,%ebp
  80113e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801141:	8b 45 08             	mov    0x8(%ebp),%eax
  801144:	8b 40 0c             	mov    0xc(%eax),%eax
  801147:	a3 00 30 80 00       	mov    %eax,0x803000
	return fsipc(FSREQ_FLUSH, NULL);
  80114c:	ba 00 00 00 00       	mov    $0x0,%edx
  801151:	b8 06 00 00 00       	mov    $0x6,%eax
  801156:	e8 6d ff ff ff       	call   8010c8 <fsipc>
}
  80115b:	c9                   	leave  
  80115c:	c3                   	ret    

0080115d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80115d:	55                   	push   %ebp
  80115e:	89 e5                	mov    %esp,%ebp
  801160:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801163:	ba 00 00 00 00       	mov    $0x0,%edx
  801168:	b8 08 00 00 00       	mov    $0x8,%eax
  80116d:	e8 56 ff ff ff       	call   8010c8 <fsipc>
}
  801172:	c9                   	leave  
  801173:	c3                   	ret    

00801174 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801174:	55                   	push   %ebp
  801175:	89 e5                	mov    %esp,%ebp
  801177:	53                   	push   %ebx
  801178:	83 ec 14             	sub    $0x14,%esp
  80117b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80117e:	8b 45 08             	mov    0x8(%ebp),%eax
  801181:	8b 40 0c             	mov    0xc(%eax),%eax
  801184:	a3 00 30 80 00       	mov    %eax,0x803000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801189:	ba 00 00 00 00       	mov    $0x0,%edx
  80118e:	b8 05 00 00 00       	mov    $0x5,%eax
  801193:	e8 30 ff ff ff       	call   8010c8 <fsipc>
  801198:	85 c0                	test   %eax,%eax
  80119a:	78 2b                	js     8011c7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80119c:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  8011a3:	00 
  8011a4:	89 1c 24             	mov    %ebx,(%esp)
  8011a7:	e8 1e f0 ff ff       	call   8001ca <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  8011ac:	a1 80 30 80 00       	mov    0x803080,%eax
  8011b1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  8011b7:	a1 84 30 80 00       	mov    0x803084,%eax
  8011bc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  8011c2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8011c7:	83 c4 14             	add    $0x14,%esp
  8011ca:	5b                   	pop    %ebx
  8011cb:	5d                   	pop    %ebp
  8011cc:	c3                   	ret    

008011cd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  8011cd:	55                   	push   %ebp
  8011ce:	89 e5                	mov    %esp,%ebp
  8011d0:	53                   	push   %ebx
  8011d1:	83 ec 14             	sub    $0x14,%esp
  8011d4:	8b 45 08             	mov    0x8(%ebp),%eax
  8011d7:	8b 55 0c             	mov    0xc(%ebp),%edx
  8011da:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  8011dd:	85 c0                	test   %eax,%eax
  8011df:	74 44                	je     801225 <devfile_write+0x58>
  8011e1:	85 d2                	test   %edx,%edx
  8011e3:	74 40                	je     801225 <devfile_write+0x58>
  8011e5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8011eb:	77 38                	ja     801225 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8011ed:	8b 40 0c             	mov    0xc(%eax),%eax
  8011f0:	a3 00 30 80 00       	mov    %eax,0x803000
    fsipcbuf.write.req_n        = n;
  8011f5:	89 1d 04 30 80 00    	mov    %ebx,0x803004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8011fb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8011ff:	89 54 24 04          	mov    %edx,0x4(%esp)
  801203:	c7 04 24 08 30 80 00 	movl   $0x803008,(%esp)
  80120a:	e8 76 f1 ff ff       	call   800385 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  80120f:	ba 00 00 00 00       	mov    $0x0,%edx
  801214:	b8 04 00 00 00       	mov    $0x4,%eax
  801219:	e8 aa fe ff ff       	call   8010c8 <fsipc>
        return r;
    return n;
  80121e:	85 c0                	test   %eax,%eax
  801220:	0f 49 c3             	cmovns %ebx,%eax
  801223:	eb 05                	jmp    80122a <devfile_write+0x5d>
  801225:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  80122a:	83 c4 14             	add    $0x14,%esp
  80122d:	5b                   	pop    %ebx
  80122e:	5d                   	pop    %ebp
  80122f:	c3                   	ret    

00801230 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801230:	55                   	push   %ebp
  801231:	89 e5                	mov    %esp,%ebp
  801233:	83 ec 18             	sub    $0x18,%esp
  801236:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801239:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80123c:	8b 45 08             	mov    0x8(%ebp),%eax
  80123f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801242:	85 c0                	test   %eax,%eax
  801244:	74 04                	je     80124a <devfile_read+0x1a>
  801246:	85 f6                	test   %esi,%esi
  801248:	75 07                	jne    801251 <devfile_read+0x21>
  80124a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80124f:	eb 39                	jmp    80128a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801251:	8b 40 0c             	mov    0xc(%eax),%eax
  801254:	a3 00 30 80 00       	mov    %eax,0x803000
  fsipcbuf.read.req_n         = n;
  801259:	8b 45 10             	mov    0x10(%ebp),%eax
  80125c:	a3 04 30 80 00       	mov    %eax,0x803004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801261:	ba 00 00 00 00       	mov    $0x0,%edx
  801266:	b8 03 00 00 00       	mov    $0x3,%eax
  80126b:	e8 58 fe ff ff       	call   8010c8 <fsipc>
  801270:	89 c3                	mov    %eax,%ebx
  801272:	85 c0                	test   %eax,%eax
  801274:	78 14                	js     80128a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801276:	89 44 24 08          	mov    %eax,0x8(%esp)
  80127a:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  801281:	00 
  801282:	89 34 24             	mov    %esi,(%esp)
  801285:	e8 fb f0 ff ff       	call   800385 <memmove>
  return r;
}
  80128a:	89 d8                	mov    %ebx,%eax
  80128c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80128f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801292:	89 ec                	mov    %ebp,%esp
  801294:	5d                   	pop    %ebp
  801295:	c3                   	ret    

00801296 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801296:	55                   	push   %ebp
  801297:	89 e5                	mov    %esp,%ebp
  801299:	53                   	push   %ebx
  80129a:	83 ec 14             	sub    $0x14,%esp
  80129d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  8012a0:	89 1c 24             	mov    %ebx,(%esp)
  8012a3:	e8 d8 ee ff ff       	call   800180 <strlen>
  8012a8:	89 c2                	mov    %eax,%edx
  8012aa:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  8012af:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  8012b5:	7f 1f                	jg     8012d6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  8012b7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8012bb:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  8012c2:	e8 03 ef ff ff       	call   8001ca <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  8012c7:	ba 00 00 00 00       	mov    $0x0,%edx
  8012cc:	b8 07 00 00 00       	mov    $0x7,%eax
  8012d1:	e8 f2 fd ff ff       	call   8010c8 <fsipc>
}
  8012d6:	83 c4 14             	add    $0x14,%esp
  8012d9:	5b                   	pop    %ebx
  8012da:	5d                   	pop    %ebp
  8012db:	c3                   	ret    

008012dc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  8012dc:	55                   	push   %ebp
  8012dd:	89 e5                	mov    %esp,%ebp
  8012df:	83 ec 28             	sub    $0x28,%esp
  8012e2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8012e5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8012e8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  8012eb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  8012f0:	85 f6                	test   %esi,%esi
  8012f2:	74 65                	je     801359 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  8012f4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  8012fb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8012fe:	89 04 24             	mov    %eax,(%esp)
  801301:	e8 75 f7 ff ff       	call   800a7b <fd_alloc>
  801306:	89 c3                	mov    %eax,%ebx
  801308:	85 c0                	test   %eax,%eax
  80130a:	78 4d                	js     801359 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80130c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801310:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801317:	e8 ae ee ff ff       	call   8001ca <strcpy>
	fsipcbuf.open.req_omode = mode;
  80131c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80131f:	a3 00 34 80 00       	mov    %eax,0x803400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801324:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801327:	b8 01 00 00 00       	mov    $0x1,%eax
  80132c:	e8 97 fd ff ff       	call   8010c8 <fsipc>
  801331:	89 c3                	mov    %eax,%ebx
  801333:	85 c0                	test   %eax,%eax
  801335:	79 15                	jns    80134c <open+0x70>
    fd_close(f, 0);
  801337:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80133e:	00 
  80133f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801342:	89 04 24             	mov    %eax,(%esp)
  801345:	e8 3a fb ff ff       	call   800e84 <fd_close>
    return r;
  80134a:	eb 0d                	jmp    801359 <open+0x7d>
  }
  return fd2num(f);
  80134c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80134f:	89 04 24             	mov    %eax,(%esp)
  801352:	e8 f9 f6 ff ff       	call   800a50 <fd2num>
  801357:	89 c3                	mov    %eax,%ebx
}
  801359:	89 d8                	mov    %ebx,%eax
  80135b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80135e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801361:	89 ec                	mov    %ebp,%esp
  801363:	5d                   	pop    %ebp
  801364:	c3                   	ret    
	...

00801370 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801370:	55                   	push   %ebp
  801371:	89 e5                	mov    %esp,%ebp
  801373:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801376:	c7 44 24 04 98 29 80 	movl   $0x802998,0x4(%esp)
  80137d:	00 
  80137e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801381:	89 04 24             	mov    %eax,(%esp)
  801384:	e8 41 ee ff ff       	call   8001ca <strcpy>
	return 0;
}
  801389:	b8 00 00 00 00       	mov    $0x0,%eax
  80138e:	c9                   	leave  
  80138f:	c3                   	ret    

00801390 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801390:	55                   	push   %ebp
  801391:	89 e5                	mov    %esp,%ebp
  801393:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801396:	8b 45 08             	mov    0x8(%ebp),%eax
  801399:	8b 40 0c             	mov    0xc(%eax),%eax
  80139c:	89 04 24             	mov    %eax,(%esp)
  80139f:	e8 9d 02 00 00       	call   801641 <nsipc_close>
}
  8013a4:	c9                   	leave  
  8013a5:	c3                   	ret    

008013a6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8013a6:	55                   	push   %ebp
  8013a7:	89 e5                	mov    %esp,%ebp
  8013a9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8013ac:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8013b3:	00 
  8013b4:	8b 45 10             	mov    0x10(%ebp),%eax
  8013b7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8013bb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8013be:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013c2:	8b 45 08             	mov    0x8(%ebp),%eax
  8013c5:	8b 40 0c             	mov    0xc(%eax),%eax
  8013c8:	89 04 24             	mov    %eax,(%esp)
  8013cb:	e8 ad 02 00 00       	call   80167d <nsipc_send>
}
  8013d0:	c9                   	leave  
  8013d1:	c3                   	ret    

008013d2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  8013d2:	55                   	push   %ebp
  8013d3:	89 e5                	mov    %esp,%ebp
  8013d5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  8013d8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8013df:	00 
  8013e0:	8b 45 10             	mov    0x10(%ebp),%eax
  8013e3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8013e7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8013ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013ee:	8b 45 08             	mov    0x8(%ebp),%eax
  8013f1:	8b 40 0c             	mov    0xc(%eax),%eax
  8013f4:	89 04 24             	mov    %eax,(%esp)
  8013f7:	e8 f4 02 00 00       	call   8016f0 <nsipc_recv>
}
  8013fc:	c9                   	leave  
  8013fd:	c3                   	ret    

008013fe <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  8013fe:	55                   	push   %ebp
  8013ff:	89 e5                	mov    %esp,%ebp
  801401:	56                   	push   %esi
  801402:	53                   	push   %ebx
  801403:	83 ec 20             	sub    $0x20,%esp
  801406:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801408:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80140b:	89 04 24             	mov    %eax,(%esp)
  80140e:	e8 68 f6 ff ff       	call   800a7b <fd_alloc>
  801413:	89 c3                	mov    %eax,%ebx
  801415:	85 c0                	test   %eax,%eax
  801417:	78 21                	js     80143a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801419:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801420:	00 
  801421:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801424:	89 44 24 04          	mov    %eax,0x4(%esp)
  801428:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80142f:	e8 f2 f4 ff ff       	call   800926 <sys_page_alloc>
  801434:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801436:	85 c0                	test   %eax,%eax
  801438:	79 0a                	jns    801444 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80143a:	89 34 24             	mov    %esi,(%esp)
  80143d:	e8 ff 01 00 00       	call   801641 <nsipc_close>
		return r;
  801442:	eb 28                	jmp    80146c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801444:	8b 15 20 60 80 00    	mov    0x806020,%edx
  80144a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80144d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80144f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801452:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801459:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80145c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80145f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801462:	89 04 24             	mov    %eax,(%esp)
  801465:	e8 e6 f5 ff ff       	call   800a50 <fd2num>
  80146a:	89 c3                	mov    %eax,%ebx
}
  80146c:	89 d8                	mov    %ebx,%eax
  80146e:	83 c4 20             	add    $0x20,%esp
  801471:	5b                   	pop    %ebx
  801472:	5e                   	pop    %esi
  801473:	5d                   	pop    %ebp
  801474:	c3                   	ret    

00801475 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  801475:	55                   	push   %ebp
  801476:	89 e5                	mov    %esp,%ebp
  801478:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  80147b:	8b 45 10             	mov    0x10(%ebp),%eax
  80147e:	89 44 24 08          	mov    %eax,0x8(%esp)
  801482:	8b 45 0c             	mov    0xc(%ebp),%eax
  801485:	89 44 24 04          	mov    %eax,0x4(%esp)
  801489:	8b 45 08             	mov    0x8(%ebp),%eax
  80148c:	89 04 24             	mov    %eax,(%esp)
  80148f:	e8 61 01 00 00       	call   8015f5 <nsipc_socket>
  801494:	85 c0                	test   %eax,%eax
  801496:	78 05                	js     80149d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  801498:	e8 61 ff ff ff       	call   8013fe <alloc_sockfd>
}
  80149d:	c9                   	leave  
  80149e:	66 90                	xchg   %ax,%ax
  8014a0:	c3                   	ret    

008014a1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8014a1:	55                   	push   %ebp
  8014a2:	89 e5                	mov    %esp,%ebp
  8014a4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8014a7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8014aa:	89 54 24 04          	mov    %edx,0x4(%esp)
  8014ae:	89 04 24             	mov    %eax,(%esp)
  8014b1:	e8 37 f6 ff ff       	call   800aed <fd_lookup>
  8014b6:	85 c0                	test   %eax,%eax
  8014b8:	78 15                	js     8014cf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8014ba:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8014bd:	8b 0a                	mov    (%edx),%ecx
  8014bf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8014c4:	3b 0d 20 60 80 00    	cmp    0x806020,%ecx
  8014ca:	75 03                	jne    8014cf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8014cc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8014cf:	c9                   	leave  
  8014d0:	c3                   	ret    

008014d1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  8014d1:	55                   	push   %ebp
  8014d2:	89 e5                	mov    %esp,%ebp
  8014d4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8014d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8014da:	e8 c2 ff ff ff       	call   8014a1 <fd2sockid>
  8014df:	85 c0                	test   %eax,%eax
  8014e1:	78 0f                	js     8014f2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  8014e3:	8b 55 0c             	mov    0xc(%ebp),%edx
  8014e6:	89 54 24 04          	mov    %edx,0x4(%esp)
  8014ea:	89 04 24             	mov    %eax,(%esp)
  8014ed:	e8 2d 01 00 00       	call   80161f <nsipc_listen>
}
  8014f2:	c9                   	leave  
  8014f3:	c3                   	ret    

008014f4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8014f4:	55                   	push   %ebp
  8014f5:	89 e5                	mov    %esp,%ebp
  8014f7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8014fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8014fd:	e8 9f ff ff ff       	call   8014a1 <fd2sockid>
  801502:	85 c0                	test   %eax,%eax
  801504:	78 16                	js     80151c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  801506:	8b 55 10             	mov    0x10(%ebp),%edx
  801509:	89 54 24 08          	mov    %edx,0x8(%esp)
  80150d:	8b 55 0c             	mov    0xc(%ebp),%edx
  801510:	89 54 24 04          	mov    %edx,0x4(%esp)
  801514:	89 04 24             	mov    %eax,(%esp)
  801517:	e8 54 02 00 00       	call   801770 <nsipc_connect>
}
  80151c:	c9                   	leave  
  80151d:	c3                   	ret    

0080151e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80151e:	55                   	push   %ebp
  80151f:	89 e5                	mov    %esp,%ebp
  801521:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801524:	8b 45 08             	mov    0x8(%ebp),%eax
  801527:	e8 75 ff ff ff       	call   8014a1 <fd2sockid>
  80152c:	85 c0                	test   %eax,%eax
  80152e:	78 0f                	js     80153f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  801530:	8b 55 0c             	mov    0xc(%ebp),%edx
  801533:	89 54 24 04          	mov    %edx,0x4(%esp)
  801537:	89 04 24             	mov    %eax,(%esp)
  80153a:	e8 1c 01 00 00       	call   80165b <nsipc_shutdown>
}
  80153f:	c9                   	leave  
  801540:	c3                   	ret    

00801541 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  801541:	55                   	push   %ebp
  801542:	89 e5                	mov    %esp,%ebp
  801544:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801547:	8b 45 08             	mov    0x8(%ebp),%eax
  80154a:	e8 52 ff ff ff       	call   8014a1 <fd2sockid>
  80154f:	85 c0                	test   %eax,%eax
  801551:	78 16                	js     801569 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  801553:	8b 55 10             	mov    0x10(%ebp),%edx
  801556:	89 54 24 08          	mov    %edx,0x8(%esp)
  80155a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80155d:	89 54 24 04          	mov    %edx,0x4(%esp)
  801561:	89 04 24             	mov    %eax,(%esp)
  801564:	e8 46 02 00 00       	call   8017af <nsipc_bind>
}
  801569:	c9                   	leave  
  80156a:	c3                   	ret    

0080156b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80156b:	55                   	push   %ebp
  80156c:	89 e5                	mov    %esp,%ebp
  80156e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801571:	8b 45 08             	mov    0x8(%ebp),%eax
  801574:	e8 28 ff ff ff       	call   8014a1 <fd2sockid>
  801579:	85 c0                	test   %eax,%eax
  80157b:	78 1f                	js     80159c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80157d:	8b 55 10             	mov    0x10(%ebp),%edx
  801580:	89 54 24 08          	mov    %edx,0x8(%esp)
  801584:	8b 55 0c             	mov    0xc(%ebp),%edx
  801587:	89 54 24 04          	mov    %edx,0x4(%esp)
  80158b:	89 04 24             	mov    %eax,(%esp)
  80158e:	e8 5b 02 00 00       	call   8017ee <nsipc_accept>
  801593:	85 c0                	test   %eax,%eax
  801595:	78 05                	js     80159c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  801597:	e8 62 fe ff ff       	call   8013fe <alloc_sockfd>
}
  80159c:	c9                   	leave  
  80159d:	8d 76 00             	lea    0x0(%esi),%esi
  8015a0:	c3                   	ret    
	...

008015b0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8015b0:	55                   	push   %ebp
  8015b1:	89 e5                	mov    %esp,%ebp
  8015b3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8015b6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8015bc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8015c3:	00 
  8015c4:	c7 44 24 08 00 50 80 	movl   $0x805000,0x8(%esp)
  8015cb:	00 
  8015cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015d0:	89 14 24             	mov    %edx,(%esp)
  8015d3:	e8 58 0f 00 00       	call   802530 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  8015d8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8015df:	00 
  8015e0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8015e7:	00 
  8015e8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8015eb:	89 04 24             	mov    %eax,(%esp)
  8015ee:	e8 af 0f 00 00       	call   8025a2 <ipc_recv>
    return r;
}
  8015f3:	c9                   	leave  
  8015f4:	c3                   	ret    

008015f5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  8015f5:	55                   	push   %ebp
  8015f6:	89 e5                	mov    %esp,%ebp
  8015f8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  8015fb:	8b 45 08             	mov    0x8(%ebp),%eax
  8015fe:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.socket.req_type = type;
  801603:	8b 45 0c             	mov    0xc(%ebp),%eax
  801606:	a3 04 50 80 00       	mov    %eax,0x805004
	nsipcbuf.socket.req_protocol = protocol;
  80160b:	8b 45 10             	mov    0x10(%ebp),%eax
  80160e:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SOCKET);
  801613:	b8 09 00 00 00       	mov    $0x9,%eax
  801618:	e8 93 ff ff ff       	call   8015b0 <nsipc>
}
  80161d:	c9                   	leave  
  80161e:	c3                   	ret    

0080161f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80161f:	55                   	push   %ebp
  801620:	89 e5                	mov    %esp,%ebp
  801622:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  801625:	8b 45 08             	mov    0x8(%ebp),%eax
  801628:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.listen.req_backlog = backlog;
  80162d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801630:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_LISTEN);
  801635:	b8 06 00 00 00       	mov    $0x6,%eax
  80163a:	e8 71 ff ff ff       	call   8015b0 <nsipc>
}
  80163f:	c9                   	leave  
  801640:	c3                   	ret    

00801641 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  801641:	55                   	push   %ebp
  801642:	89 e5                	mov    %esp,%ebp
  801644:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  801647:	8b 45 08             	mov    0x8(%ebp),%eax
  80164a:	a3 00 50 80 00       	mov    %eax,0x805000
	return nsipc(NSREQ_CLOSE);
  80164f:	b8 04 00 00 00       	mov    $0x4,%eax
  801654:	e8 57 ff ff ff       	call   8015b0 <nsipc>
}
  801659:	c9                   	leave  
  80165a:	c3                   	ret    

0080165b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80165b:	55                   	push   %ebp
  80165c:	89 e5                	mov    %esp,%ebp
  80165e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  801661:	8b 45 08             	mov    0x8(%ebp),%eax
  801664:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.shutdown.req_how = how;
  801669:	8b 45 0c             	mov    0xc(%ebp),%eax
  80166c:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_SHUTDOWN);
  801671:	b8 03 00 00 00       	mov    $0x3,%eax
  801676:	e8 35 ff ff ff       	call   8015b0 <nsipc>
}
  80167b:	c9                   	leave  
  80167c:	c3                   	ret    

0080167d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80167d:	55                   	push   %ebp
  80167e:	89 e5                	mov    %esp,%ebp
  801680:	53                   	push   %ebx
  801681:	83 ec 14             	sub    $0x14,%esp
  801684:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  801687:	8b 45 08             	mov    0x8(%ebp),%eax
  80168a:	a3 00 50 80 00       	mov    %eax,0x805000
	assert(size < 1600);
  80168f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  801695:	7e 24                	jle    8016bb <nsipc_send+0x3e>
  801697:	c7 44 24 0c a4 29 80 	movl   $0x8029a4,0xc(%esp)
  80169e:	00 
  80169f:	c7 44 24 08 b0 29 80 	movl   $0x8029b0,0x8(%esp)
  8016a6:	00 
  8016a7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8016ae:	00 
  8016af:	c7 04 24 c5 29 80 00 	movl   $0x8029c5,(%esp)
  8016b6:	e8 29 07 00 00       	call   801de4 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8016bb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8016bf:	8b 45 0c             	mov    0xc(%ebp),%eax
  8016c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016c6:	c7 04 24 0c 50 80 00 	movl   $0x80500c,(%esp)
  8016cd:	e8 b3 ec ff ff       	call   800385 <memmove>
	nsipcbuf.send.req_size = size;
  8016d2:	89 1d 04 50 80 00    	mov    %ebx,0x805004
	nsipcbuf.send.req_flags = flags;
  8016d8:	8b 45 14             	mov    0x14(%ebp),%eax
  8016db:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SEND);
  8016e0:	b8 08 00 00 00       	mov    $0x8,%eax
  8016e5:	e8 c6 fe ff ff       	call   8015b0 <nsipc>
}
  8016ea:	83 c4 14             	add    $0x14,%esp
  8016ed:	5b                   	pop    %ebx
  8016ee:	5d                   	pop    %ebp
  8016ef:	c3                   	ret    

008016f0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  8016f0:	55                   	push   %ebp
  8016f1:	89 e5                	mov    %esp,%ebp
  8016f3:	56                   	push   %esi
  8016f4:	53                   	push   %ebx
  8016f5:	83 ec 10             	sub    $0x10,%esp
  8016f8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  8016fb:	8b 45 08             	mov    0x8(%ebp),%eax
  8016fe:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.recv.req_len = len;
  801703:	89 35 04 50 80 00    	mov    %esi,0x805004
	nsipcbuf.recv.req_flags = flags;
  801709:	8b 45 14             	mov    0x14(%ebp),%eax
  80170c:	a3 08 50 80 00       	mov    %eax,0x805008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  801711:	b8 07 00 00 00       	mov    $0x7,%eax
  801716:	e8 95 fe ff ff       	call   8015b0 <nsipc>
  80171b:	89 c3                	mov    %eax,%ebx
  80171d:	85 c0                	test   %eax,%eax
  80171f:	78 46                	js     801767 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  801721:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  801726:	7f 04                	jg     80172c <nsipc_recv+0x3c>
  801728:	39 c6                	cmp    %eax,%esi
  80172a:	7d 24                	jge    801750 <nsipc_recv+0x60>
  80172c:	c7 44 24 0c d1 29 80 	movl   $0x8029d1,0xc(%esp)
  801733:	00 
  801734:	c7 44 24 08 b0 29 80 	movl   $0x8029b0,0x8(%esp)
  80173b:	00 
  80173c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  801743:	00 
  801744:	c7 04 24 c5 29 80 00 	movl   $0x8029c5,(%esp)
  80174b:	e8 94 06 00 00       	call   801de4 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  801750:	89 44 24 08          	mov    %eax,0x8(%esp)
  801754:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  80175b:	00 
  80175c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80175f:	89 04 24             	mov    %eax,(%esp)
  801762:	e8 1e ec ff ff       	call   800385 <memmove>
	}

	return r;
}
  801767:	89 d8                	mov    %ebx,%eax
  801769:	83 c4 10             	add    $0x10,%esp
  80176c:	5b                   	pop    %ebx
  80176d:	5e                   	pop    %esi
  80176e:	5d                   	pop    %ebp
  80176f:	c3                   	ret    

00801770 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  801770:	55                   	push   %ebp
  801771:	89 e5                	mov    %esp,%ebp
  801773:	53                   	push   %ebx
  801774:	83 ec 14             	sub    $0x14,%esp
  801777:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80177a:	8b 45 08             	mov    0x8(%ebp),%eax
  80177d:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  801782:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801786:	8b 45 0c             	mov    0xc(%ebp),%eax
  801789:	89 44 24 04          	mov    %eax,0x4(%esp)
  80178d:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  801794:	e8 ec eb ff ff       	call   800385 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  801799:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_CONNECT);
  80179f:	b8 05 00 00 00       	mov    $0x5,%eax
  8017a4:	e8 07 fe ff ff       	call   8015b0 <nsipc>
}
  8017a9:	83 c4 14             	add    $0x14,%esp
  8017ac:	5b                   	pop    %ebx
  8017ad:	5d                   	pop    %ebp
  8017ae:	c3                   	ret    

008017af <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8017af:	55                   	push   %ebp
  8017b0:	89 e5                	mov    %esp,%ebp
  8017b2:	53                   	push   %ebx
  8017b3:	83 ec 14             	sub    $0x14,%esp
  8017b6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8017b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8017bc:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8017c1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8017c5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8017c8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017cc:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  8017d3:	e8 ad eb ff ff       	call   800385 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8017d8:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_BIND);
  8017de:	b8 02 00 00 00       	mov    $0x2,%eax
  8017e3:	e8 c8 fd ff ff       	call   8015b0 <nsipc>
}
  8017e8:	83 c4 14             	add    $0x14,%esp
  8017eb:	5b                   	pop    %ebx
  8017ec:	5d                   	pop    %ebp
  8017ed:	c3                   	ret    

008017ee <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8017ee:	55                   	push   %ebp
  8017ef:	89 e5                	mov    %esp,%ebp
  8017f1:	83 ec 18             	sub    $0x18,%esp
  8017f4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8017f7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8017fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8017fd:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  801802:	b8 01 00 00 00       	mov    $0x1,%eax
  801807:	e8 a4 fd ff ff       	call   8015b0 <nsipc>
  80180c:	89 c3                	mov    %eax,%ebx
  80180e:	85 c0                	test   %eax,%eax
  801810:	78 25                	js     801837 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  801812:	be 10 50 80 00       	mov    $0x805010,%esi
  801817:	8b 06                	mov    (%esi),%eax
  801819:	89 44 24 08          	mov    %eax,0x8(%esp)
  80181d:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  801824:	00 
  801825:	8b 45 0c             	mov    0xc(%ebp),%eax
  801828:	89 04 24             	mov    %eax,(%esp)
  80182b:	e8 55 eb ff ff       	call   800385 <memmove>
		*addrlen = ret->ret_addrlen;
  801830:	8b 16                	mov    (%esi),%edx
  801832:	8b 45 10             	mov    0x10(%ebp),%eax
  801835:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  801837:	89 d8                	mov    %ebx,%eax
  801839:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80183c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80183f:	89 ec                	mov    %ebp,%esp
  801841:	5d                   	pop    %ebp
  801842:	c3                   	ret    
	...

00801850 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  801850:	55                   	push   %ebp
  801851:	89 e5                	mov    %esp,%ebp
  801853:	83 ec 18             	sub    $0x18,%esp
  801856:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801859:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80185c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80185f:	8b 45 08             	mov    0x8(%ebp),%eax
  801862:	89 04 24             	mov    %eax,(%esp)
  801865:	e8 f6 f1 ff ff       	call   800a60 <fd2data>
  80186a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80186c:	c7 44 24 04 e6 29 80 	movl   $0x8029e6,0x4(%esp)
  801873:	00 
  801874:	89 34 24             	mov    %esi,(%esp)
  801877:	e8 4e e9 ff ff       	call   8001ca <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80187c:	8b 43 04             	mov    0x4(%ebx),%eax
  80187f:	2b 03                	sub    (%ebx),%eax
  801881:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  801887:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80188e:	00 00 00 
	stat->st_dev = &devpipe;
  801891:	c7 86 88 00 00 00 3c 	movl   $0x80603c,0x88(%esi)
  801898:	60 80 00 
	return 0;
}
  80189b:	b8 00 00 00 00       	mov    $0x0,%eax
  8018a0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8018a3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8018a6:	89 ec                	mov    %ebp,%esp
  8018a8:	5d                   	pop    %ebp
  8018a9:	c3                   	ret    

008018aa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8018aa:	55                   	push   %ebp
  8018ab:	89 e5                	mov    %esp,%ebp
  8018ad:	53                   	push   %ebx
  8018ae:	83 ec 14             	sub    $0x14,%esp
  8018b1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8018b4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8018b8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018bf:	e8 a6 ef ff ff       	call   80086a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8018c4:	89 1c 24             	mov    %ebx,(%esp)
  8018c7:	e8 94 f1 ff ff       	call   800a60 <fd2data>
  8018cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018d0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018d7:	e8 8e ef ff ff       	call   80086a <sys_page_unmap>
}
  8018dc:	83 c4 14             	add    $0x14,%esp
  8018df:	5b                   	pop    %ebx
  8018e0:	5d                   	pop    %ebp
  8018e1:	c3                   	ret    

008018e2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8018e2:	55                   	push   %ebp
  8018e3:	89 e5                	mov    %esp,%ebp
  8018e5:	57                   	push   %edi
  8018e6:	56                   	push   %esi
  8018e7:	53                   	push   %ebx
  8018e8:	83 ec 2c             	sub    $0x2c,%esp
  8018eb:	89 c7                	mov    %eax,%edi
  8018ed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8018f0:	a1 74 60 80 00       	mov    0x806074,%eax
  8018f5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8018f8:	89 3c 24             	mov    %edi,(%esp)
  8018fb:	e8 f4 0c 00 00       	call   8025f4 <pageref>
  801900:	89 c6                	mov    %eax,%esi
  801902:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801905:	89 04 24             	mov    %eax,(%esp)
  801908:	e8 e7 0c 00 00       	call   8025f4 <pageref>
  80190d:	39 c6                	cmp    %eax,%esi
  80190f:	0f 94 c0             	sete   %al
  801912:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  801915:	8b 15 74 60 80 00    	mov    0x806074,%edx
  80191b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80191e:	39 cb                	cmp    %ecx,%ebx
  801920:	75 08                	jne    80192a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  801922:	83 c4 2c             	add    $0x2c,%esp
  801925:	5b                   	pop    %ebx
  801926:	5e                   	pop    %esi
  801927:	5f                   	pop    %edi
  801928:	5d                   	pop    %ebp
  801929:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80192a:	83 f8 01             	cmp    $0x1,%eax
  80192d:	75 c1                	jne    8018f0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80192f:	8b 52 58             	mov    0x58(%edx),%edx
  801932:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801936:	89 54 24 08          	mov    %edx,0x8(%esp)
  80193a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80193e:	c7 04 24 ed 29 80 00 	movl   $0x8029ed,(%esp)
  801945:	e8 5f 05 00 00       	call   801ea9 <cprintf>
  80194a:	eb a4                	jmp    8018f0 <_pipeisclosed+0xe>

0080194c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80194c:	55                   	push   %ebp
  80194d:	89 e5                	mov    %esp,%ebp
  80194f:	57                   	push   %edi
  801950:	56                   	push   %esi
  801951:	53                   	push   %ebx
  801952:	83 ec 1c             	sub    $0x1c,%esp
  801955:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  801958:	89 34 24             	mov    %esi,(%esp)
  80195b:	e8 00 f1 ff ff       	call   800a60 <fd2data>
  801960:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  801962:	bf 00 00 00 00       	mov    $0x0,%edi
  801967:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80196b:	75 54                	jne    8019c1 <devpipe_write+0x75>
  80196d:	eb 60                	jmp    8019cf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80196f:	89 da                	mov    %ebx,%edx
  801971:	89 f0                	mov    %esi,%eax
  801973:	e8 6a ff ff ff       	call   8018e2 <_pipeisclosed>
  801978:	85 c0                	test   %eax,%eax
  80197a:	74 07                	je     801983 <devpipe_write+0x37>
  80197c:	b8 00 00 00 00       	mov    $0x0,%eax
  801981:	eb 53                	jmp    8019d6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  801983:	90                   	nop
  801984:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  801988:	e8 f8 ef ff ff       	call   800985 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80198d:	8b 43 04             	mov    0x4(%ebx),%eax
  801990:	8b 13                	mov    (%ebx),%edx
  801992:	83 c2 20             	add    $0x20,%edx
  801995:	39 d0                	cmp    %edx,%eax
  801997:	73 d6                	jae    80196f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  801999:	89 c2                	mov    %eax,%edx
  80199b:	c1 fa 1f             	sar    $0x1f,%edx
  80199e:	c1 ea 1b             	shr    $0x1b,%edx
  8019a1:	01 d0                	add    %edx,%eax
  8019a3:	83 e0 1f             	and    $0x1f,%eax
  8019a6:	29 d0                	sub    %edx,%eax
  8019a8:	89 c2                	mov    %eax,%edx
  8019aa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8019ad:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8019b1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8019b5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8019b9:	83 c7 01             	add    $0x1,%edi
  8019bc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8019bf:	76 13                	jbe    8019d4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8019c1:	8b 43 04             	mov    0x4(%ebx),%eax
  8019c4:	8b 13                	mov    (%ebx),%edx
  8019c6:	83 c2 20             	add    $0x20,%edx
  8019c9:	39 d0                	cmp    %edx,%eax
  8019cb:	73 a2                	jae    80196f <devpipe_write+0x23>
  8019cd:	eb ca                	jmp    801999 <devpipe_write+0x4d>
  8019cf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  8019d4:	89 f8                	mov    %edi,%eax
}
  8019d6:	83 c4 1c             	add    $0x1c,%esp
  8019d9:	5b                   	pop    %ebx
  8019da:	5e                   	pop    %esi
  8019db:	5f                   	pop    %edi
  8019dc:	5d                   	pop    %ebp
  8019dd:	c3                   	ret    

008019de <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  8019de:	55                   	push   %ebp
  8019df:	89 e5                	mov    %esp,%ebp
  8019e1:	83 ec 28             	sub    $0x28,%esp
  8019e4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8019e7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8019ea:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8019ed:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8019f0:	89 3c 24             	mov    %edi,(%esp)
  8019f3:	e8 68 f0 ff ff       	call   800a60 <fd2data>
  8019f8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8019fa:	be 00 00 00 00       	mov    $0x0,%esi
  8019ff:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  801a03:	75 4c                	jne    801a51 <devpipe_read+0x73>
  801a05:	eb 5b                	jmp    801a62 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  801a07:	89 f0                	mov    %esi,%eax
  801a09:	eb 5e                	jmp    801a69 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  801a0b:	89 da                	mov    %ebx,%edx
  801a0d:	89 f8                	mov    %edi,%eax
  801a0f:	90                   	nop
  801a10:	e8 cd fe ff ff       	call   8018e2 <_pipeisclosed>
  801a15:	85 c0                	test   %eax,%eax
  801a17:	74 07                	je     801a20 <devpipe_read+0x42>
  801a19:	b8 00 00 00 00       	mov    $0x0,%eax
  801a1e:	eb 49                	jmp    801a69 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  801a20:	e8 60 ef ff ff       	call   800985 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  801a25:	8b 03                	mov    (%ebx),%eax
  801a27:	3b 43 04             	cmp    0x4(%ebx),%eax
  801a2a:	74 df                	je     801a0b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  801a2c:	89 c2                	mov    %eax,%edx
  801a2e:	c1 fa 1f             	sar    $0x1f,%edx
  801a31:	c1 ea 1b             	shr    $0x1b,%edx
  801a34:	01 d0                	add    %edx,%eax
  801a36:	83 e0 1f             	and    $0x1f,%eax
  801a39:	29 d0                	sub    %edx,%eax
  801a3b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  801a40:	8b 55 0c             	mov    0xc(%ebp),%edx
  801a43:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  801a46:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  801a49:	83 c6 01             	add    $0x1,%esi
  801a4c:	39 75 10             	cmp    %esi,0x10(%ebp)
  801a4f:	76 16                	jbe    801a67 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  801a51:	8b 03                	mov    (%ebx),%eax
  801a53:	3b 43 04             	cmp    0x4(%ebx),%eax
  801a56:	75 d4                	jne    801a2c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  801a58:	85 f6                	test   %esi,%esi
  801a5a:	75 ab                	jne    801a07 <devpipe_read+0x29>
  801a5c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  801a60:	eb a9                	jmp    801a0b <devpipe_read+0x2d>
  801a62:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  801a67:	89 f0                	mov    %esi,%eax
}
  801a69:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801a6c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801a6f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801a72:	89 ec                	mov    %ebp,%esp
  801a74:	5d                   	pop    %ebp
  801a75:	c3                   	ret    

00801a76 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  801a76:	55                   	push   %ebp
  801a77:	89 e5                	mov    %esp,%ebp
  801a79:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801a7c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a7f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a83:	8b 45 08             	mov    0x8(%ebp),%eax
  801a86:	89 04 24             	mov    %eax,(%esp)
  801a89:	e8 5f f0 ff ff       	call   800aed <fd_lookup>
  801a8e:	85 c0                	test   %eax,%eax
  801a90:	78 15                	js     801aa7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  801a92:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a95:	89 04 24             	mov    %eax,(%esp)
  801a98:	e8 c3 ef ff ff       	call   800a60 <fd2data>
	return _pipeisclosed(fd, p);
  801a9d:	89 c2                	mov    %eax,%edx
  801a9f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801aa2:	e8 3b fe ff ff       	call   8018e2 <_pipeisclosed>
}
  801aa7:	c9                   	leave  
  801aa8:	c3                   	ret    

00801aa9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  801aa9:	55                   	push   %ebp
  801aaa:	89 e5                	mov    %esp,%ebp
  801aac:	83 ec 48             	sub    $0x48,%esp
  801aaf:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801ab2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801ab5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801ab8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  801abb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801abe:	89 04 24             	mov    %eax,(%esp)
  801ac1:	e8 b5 ef ff ff       	call   800a7b <fd_alloc>
  801ac6:	89 c3                	mov    %eax,%ebx
  801ac8:	85 c0                	test   %eax,%eax
  801aca:	0f 88 42 01 00 00    	js     801c12 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801ad0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  801ad7:	00 
  801ad8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801adb:	89 44 24 04          	mov    %eax,0x4(%esp)
  801adf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ae6:	e8 3b ee ff ff       	call   800926 <sys_page_alloc>
  801aeb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  801aed:	85 c0                	test   %eax,%eax
  801aef:	0f 88 1d 01 00 00    	js     801c12 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  801af5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801af8:	89 04 24             	mov    %eax,(%esp)
  801afb:	e8 7b ef ff ff       	call   800a7b <fd_alloc>
  801b00:	89 c3                	mov    %eax,%ebx
  801b02:	85 c0                	test   %eax,%eax
  801b04:	0f 88 f5 00 00 00    	js     801bff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801b0a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  801b11:	00 
  801b12:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801b15:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b19:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b20:	e8 01 ee ff ff       	call   800926 <sys_page_alloc>
  801b25:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  801b27:	85 c0                	test   %eax,%eax
  801b29:	0f 88 d0 00 00 00    	js     801bff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  801b2f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801b32:	89 04 24             	mov    %eax,(%esp)
  801b35:	e8 26 ef ff ff       	call   800a60 <fd2data>
  801b3a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801b3c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  801b43:	00 
  801b44:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b48:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b4f:	e8 d2 ed ff ff       	call   800926 <sys_page_alloc>
  801b54:	89 c3                	mov    %eax,%ebx
  801b56:	85 c0                	test   %eax,%eax
  801b58:	0f 88 8e 00 00 00    	js     801bec <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801b5e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801b61:	89 04 24             	mov    %eax,(%esp)
  801b64:	e8 f7 ee ff ff       	call   800a60 <fd2data>
  801b69:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  801b70:	00 
  801b71:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801b75:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801b7c:	00 
  801b7d:	89 74 24 04          	mov    %esi,0x4(%esp)
  801b81:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b88:	e8 3b ed ff ff       	call   8008c8 <sys_page_map>
  801b8d:	89 c3                	mov    %eax,%ebx
  801b8f:	85 c0                	test   %eax,%eax
  801b91:	78 49                	js     801bdc <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  801b93:	b8 3c 60 80 00       	mov    $0x80603c,%eax
  801b98:	8b 08                	mov    (%eax),%ecx
  801b9a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801b9d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  801b9f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801ba2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  801ba9:	8b 10                	mov    (%eax),%edx
  801bab:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bae:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  801bb0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bb3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  801bba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801bbd:	89 04 24             	mov    %eax,(%esp)
  801bc0:	e8 8b ee ff ff       	call   800a50 <fd2num>
  801bc5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  801bc7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bca:	89 04 24             	mov    %eax,(%esp)
  801bcd:	e8 7e ee ff ff       	call   800a50 <fd2num>
  801bd2:	89 47 04             	mov    %eax,0x4(%edi)
  801bd5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  801bda:	eb 36                	jmp    801c12 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  801bdc:	89 74 24 04          	mov    %esi,0x4(%esp)
  801be0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801be7:	e8 7e ec ff ff       	call   80086a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  801bec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bef:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bf3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801bfa:	e8 6b ec ff ff       	call   80086a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  801bff:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801c02:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c06:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c0d:	e8 58 ec ff ff       	call   80086a <sys_page_unmap>
    err:
	return r;
}
  801c12:	89 d8                	mov    %ebx,%eax
  801c14:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801c17:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801c1a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801c1d:	89 ec                	mov    %ebp,%esp
  801c1f:	5d                   	pop    %ebp
  801c20:	c3                   	ret    
	...

00801c30 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  801c30:	55                   	push   %ebp
  801c31:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  801c33:	b8 00 00 00 00       	mov    $0x0,%eax
  801c38:	5d                   	pop    %ebp
  801c39:	c3                   	ret    

00801c3a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  801c3a:	55                   	push   %ebp
  801c3b:	89 e5                	mov    %esp,%ebp
  801c3d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  801c40:	c7 44 24 04 05 2a 80 	movl   $0x802a05,0x4(%esp)
  801c47:	00 
  801c48:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c4b:	89 04 24             	mov    %eax,(%esp)
  801c4e:	e8 77 e5 ff ff       	call   8001ca <strcpy>
	return 0;
}
  801c53:	b8 00 00 00 00       	mov    $0x0,%eax
  801c58:	c9                   	leave  
  801c59:	c3                   	ret    

00801c5a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  801c5a:	55                   	push   %ebp
  801c5b:	89 e5                	mov    %esp,%ebp
  801c5d:	57                   	push   %edi
  801c5e:	56                   	push   %esi
  801c5f:	53                   	push   %ebx
  801c60:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  801c66:	b8 00 00 00 00       	mov    $0x0,%eax
  801c6b:	be 00 00 00 00       	mov    $0x0,%esi
  801c70:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  801c74:	74 41                	je     801cb7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  801c76:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  801c7c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801c7f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  801c81:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  801c87:	ba 7f 00 00 00       	mov    $0x7f,%edx
  801c8c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  801c8f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801c93:	03 45 0c             	add    0xc(%ebp),%eax
  801c96:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c9a:	89 3c 24             	mov    %edi,(%esp)
  801c9d:	e8 e3 e6 ff ff       	call   800385 <memmove>
		sys_cputs(buf, m);
  801ca2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801ca6:	89 3c 24             	mov    %edi,(%esp)
  801ca9:	e8 12 e9 ff ff       	call   8005c0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  801cae:	01 de                	add    %ebx,%esi
  801cb0:	89 f0                	mov    %esi,%eax
  801cb2:	3b 75 10             	cmp    0x10(%ebp),%esi
  801cb5:	72 c5                	jb     801c7c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  801cb7:	89 f0                	mov    %esi,%eax
  801cb9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  801cbf:	5b                   	pop    %ebx
  801cc0:	5e                   	pop    %esi
  801cc1:	5f                   	pop    %edi
  801cc2:	5d                   	pop    %ebp
  801cc3:	c3                   	ret    

00801cc4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  801cc4:	55                   	push   %ebp
  801cc5:	89 e5                	mov    %esp,%ebp
  801cc7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  801cca:	8b 45 08             	mov    0x8(%ebp),%eax
  801ccd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  801cd0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801cd7:	00 
  801cd8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  801cdb:	89 04 24             	mov    %eax,(%esp)
  801cde:	e8 dd e8 ff ff       	call   8005c0 <sys_cputs>
}
  801ce3:	c9                   	leave  
  801ce4:	c3                   	ret    

00801ce5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  801ce5:	55                   	push   %ebp
  801ce6:	89 e5                	mov    %esp,%ebp
  801ce8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  801ceb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  801cef:	75 07                	jne    801cf8 <devcons_read+0x13>
  801cf1:	eb 2d                	jmp    801d20 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  801cf3:	e8 8d ec ff ff       	call   800985 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  801cf8:	90                   	nop
  801cf9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  801d00:	e8 87 e8 ff ff       	call   80058c <sys_cgetc>
  801d05:	85 c0                	test   %eax,%eax
  801d07:	74 ea                	je     801cf3 <devcons_read+0xe>
  801d09:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  801d0b:	85 c0                	test   %eax,%eax
  801d0d:	78 16                	js     801d25 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  801d0f:	83 f8 04             	cmp    $0x4,%eax
  801d12:	74 0c                	je     801d20 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  801d14:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d17:	88 10                	mov    %dl,(%eax)
  801d19:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  801d1e:	eb 05                	jmp    801d25 <devcons_read+0x40>
  801d20:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801d25:	c9                   	leave  
  801d26:	c3                   	ret    

00801d27 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  801d27:	55                   	push   %ebp
  801d28:	89 e5                	mov    %esp,%ebp
  801d2a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  801d2d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d30:	89 04 24             	mov    %eax,(%esp)
  801d33:	e8 43 ed ff ff       	call   800a7b <fd_alloc>
  801d38:	85 c0                	test   %eax,%eax
  801d3a:	78 3f                	js     801d7b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  801d3c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  801d43:	00 
  801d44:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d47:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d4b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d52:	e8 cf eb ff ff       	call   800926 <sys_page_alloc>
  801d57:	85 c0                	test   %eax,%eax
  801d59:	78 20                	js     801d7b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  801d5b:	8b 15 58 60 80 00    	mov    0x806058,%edx
  801d61:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d64:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  801d66:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d69:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  801d70:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d73:	89 04 24             	mov    %eax,(%esp)
  801d76:	e8 d5 ec ff ff       	call   800a50 <fd2num>
}
  801d7b:	c9                   	leave  
  801d7c:	c3                   	ret    

00801d7d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  801d7d:	55                   	push   %ebp
  801d7e:	89 e5                	mov    %esp,%ebp
  801d80:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801d83:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d86:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d8a:	8b 45 08             	mov    0x8(%ebp),%eax
  801d8d:	89 04 24             	mov    %eax,(%esp)
  801d90:	e8 58 ed ff ff       	call   800aed <fd_lookup>
  801d95:	85 c0                	test   %eax,%eax
  801d97:	78 11                	js     801daa <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  801d99:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d9c:	8b 00                	mov    (%eax),%eax
  801d9e:	3b 05 58 60 80 00    	cmp    0x806058,%eax
  801da4:	0f 94 c0             	sete   %al
  801da7:	0f b6 c0             	movzbl %al,%eax
}
  801daa:	c9                   	leave  
  801dab:	c3                   	ret    

00801dac <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  801dac:	55                   	push   %ebp
  801dad:	89 e5                	mov    %esp,%ebp
  801daf:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  801db2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  801db9:	00 
  801dba:	8d 45 f7             	lea    -0x9(%ebp),%eax
  801dbd:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dc1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801dc8:	e8 86 ef ff ff       	call   800d53 <read>
	if (r < 0)
  801dcd:	85 c0                	test   %eax,%eax
  801dcf:	78 0f                	js     801de0 <getchar+0x34>
		return r;
	if (r < 1)
  801dd1:	85 c0                	test   %eax,%eax
  801dd3:	7f 07                	jg     801ddc <getchar+0x30>
  801dd5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  801dda:	eb 04                	jmp    801de0 <getchar+0x34>
		return -E_EOF;
	return c;
  801ddc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  801de0:	c9                   	leave  
  801de1:	c3                   	ret    
	...

00801de4 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  801de4:	55                   	push   %ebp
  801de5:	89 e5                	mov    %esp,%ebp
  801de7:	53                   	push   %ebx
  801de8:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  801deb:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  801dee:	a1 78 60 80 00       	mov    0x806078,%eax
  801df3:	85 c0                	test   %eax,%eax
  801df5:	74 10                	je     801e07 <_panic+0x23>
		cprintf("%s: ", argv0);
  801df7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dfb:	c7 04 24 11 2a 80 00 	movl   $0x802a11,(%esp)
  801e02:	e8 a2 00 00 00       	call   801ea9 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  801e07:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e0a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801e0e:	8b 45 08             	mov    0x8(%ebp),%eax
  801e11:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e15:	a1 00 60 80 00       	mov    0x806000,%eax
  801e1a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e1e:	c7 04 24 16 2a 80 00 	movl   $0x802a16,(%esp)
  801e25:	e8 7f 00 00 00       	call   801ea9 <cprintf>
	vcprintf(fmt, ap);
  801e2a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e2e:	8b 45 10             	mov    0x10(%ebp),%eax
  801e31:	89 04 24             	mov    %eax,(%esp)
  801e34:	e8 0f 00 00 00       	call   801e48 <vcprintf>
	cprintf("\n");
  801e39:	c7 04 24 fe 29 80 00 	movl   $0x8029fe,(%esp)
  801e40:	e8 64 00 00 00       	call   801ea9 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  801e45:	cc                   	int3   
  801e46:	eb fd                	jmp    801e45 <_panic+0x61>

00801e48 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  801e48:	55                   	push   %ebp
  801e49:	89 e5                	mov    %esp,%ebp
  801e4b:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  801e51:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  801e58:	00 00 00 
	b.cnt = 0;
  801e5b:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  801e62:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  801e65:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e68:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801e6c:	8b 45 08             	mov    0x8(%ebp),%eax
  801e6f:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e73:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  801e79:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e7d:	c7 04 24 c3 1e 80 00 	movl   $0x801ec3,(%esp)
  801e84:	e8 d4 01 00 00       	call   80205d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  801e89:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  801e8f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e93:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  801e99:	89 04 24             	mov    %eax,(%esp)
  801e9c:	e8 1f e7 ff ff       	call   8005c0 <sys_cputs>

	return b.cnt;
}
  801ea1:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  801ea7:	c9                   	leave  
  801ea8:	c3                   	ret    

00801ea9 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  801ea9:	55                   	push   %ebp
  801eaa:	89 e5                	mov    %esp,%ebp
  801eac:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  801eaf:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  801eb2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eb6:	8b 45 08             	mov    0x8(%ebp),%eax
  801eb9:	89 04 24             	mov    %eax,(%esp)
  801ebc:	e8 87 ff ff ff       	call   801e48 <vcprintf>
	va_end(ap);

	return cnt;
}
  801ec1:	c9                   	leave  
  801ec2:	c3                   	ret    

00801ec3 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  801ec3:	55                   	push   %ebp
  801ec4:	89 e5                	mov    %esp,%ebp
  801ec6:	53                   	push   %ebx
  801ec7:	83 ec 14             	sub    $0x14,%esp
  801eca:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  801ecd:	8b 03                	mov    (%ebx),%eax
  801ecf:	8b 55 08             	mov    0x8(%ebp),%edx
  801ed2:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  801ed6:	83 c0 01             	add    $0x1,%eax
  801ed9:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  801edb:	3d ff 00 00 00       	cmp    $0xff,%eax
  801ee0:	75 19                	jne    801efb <putch+0x38>
		sys_cputs(b->buf, b->idx);
  801ee2:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  801ee9:	00 
  801eea:	8d 43 08             	lea    0x8(%ebx),%eax
  801eed:	89 04 24             	mov    %eax,(%esp)
  801ef0:	e8 cb e6 ff ff       	call   8005c0 <sys_cputs>
		b->idx = 0;
  801ef5:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  801efb:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  801eff:	83 c4 14             	add    $0x14,%esp
  801f02:	5b                   	pop    %ebx
  801f03:	5d                   	pop    %ebp
  801f04:	c3                   	ret    
	...

00801f10 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  801f10:	55                   	push   %ebp
  801f11:	89 e5                	mov    %esp,%ebp
  801f13:	57                   	push   %edi
  801f14:	56                   	push   %esi
  801f15:	53                   	push   %ebx
  801f16:	83 ec 4c             	sub    $0x4c,%esp
  801f19:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801f1c:	89 d6                	mov    %edx,%esi
  801f1e:	8b 45 08             	mov    0x8(%ebp),%eax
  801f21:	89 45 d8             	mov    %eax,-0x28(%ebp)
  801f24:	8b 55 0c             	mov    0xc(%ebp),%edx
  801f27:	89 55 e0             	mov    %edx,-0x20(%ebp)
  801f2a:	8b 45 10             	mov    0x10(%ebp),%eax
  801f2d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  801f30:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  801f33:	89 45 dc             	mov    %eax,-0x24(%ebp)
  801f36:	b9 00 00 00 00       	mov    $0x0,%ecx
  801f3b:	39 d1                	cmp    %edx,%ecx
  801f3d:	72 15                	jb     801f54 <printnum+0x44>
  801f3f:	77 07                	ja     801f48 <printnum+0x38>
  801f41:	8b 55 d8             	mov    -0x28(%ebp),%edx
  801f44:	39 d0                	cmp    %edx,%eax
  801f46:	76 0c                	jbe    801f54 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  801f48:	83 eb 01             	sub    $0x1,%ebx
  801f4b:	85 db                	test   %ebx,%ebx
  801f4d:	8d 76 00             	lea    0x0(%esi),%esi
  801f50:	7f 61                	jg     801fb3 <printnum+0xa3>
  801f52:	eb 70                	jmp    801fc4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  801f54:	89 7c 24 10          	mov    %edi,0x10(%esp)
  801f58:	83 eb 01             	sub    $0x1,%ebx
  801f5b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801f5f:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f63:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  801f67:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  801f6b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  801f6e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  801f71:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  801f74:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801f78:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801f7f:	00 
  801f80:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801f83:	89 04 24             	mov    %eax,(%esp)
  801f86:	8b 55 e0             	mov    -0x20(%ebp),%edx
  801f89:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f8d:	e8 ae 06 00 00       	call   802640 <__udivdi3>
  801f92:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  801f95:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  801f98:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801f9c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801fa0:	89 04 24             	mov    %eax,(%esp)
  801fa3:	89 54 24 04          	mov    %edx,0x4(%esp)
  801fa7:	89 f2                	mov    %esi,%edx
  801fa9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801fac:	e8 5f ff ff ff       	call   801f10 <printnum>
  801fb1:	eb 11                	jmp    801fc4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  801fb3:	89 74 24 04          	mov    %esi,0x4(%esp)
  801fb7:	89 3c 24             	mov    %edi,(%esp)
  801fba:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  801fbd:	83 eb 01             	sub    $0x1,%ebx
  801fc0:	85 db                	test   %ebx,%ebx
  801fc2:	7f ef                	jg     801fb3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  801fc4:	89 74 24 04          	mov    %esi,0x4(%esp)
  801fc8:	8b 74 24 04          	mov    0x4(%esp),%esi
  801fcc:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801fcf:	89 44 24 08          	mov    %eax,0x8(%esp)
  801fd3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801fda:	00 
  801fdb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  801fde:	89 14 24             	mov    %edx,(%esp)
  801fe1:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  801fe4:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  801fe8:	e8 83 07 00 00       	call   802770 <__umoddi3>
  801fed:	89 74 24 04          	mov    %esi,0x4(%esp)
  801ff1:	0f be 80 32 2a 80 00 	movsbl 0x802a32(%eax),%eax
  801ff8:	89 04 24             	mov    %eax,(%esp)
  801ffb:	ff 55 e4             	call   *-0x1c(%ebp)
}
  801ffe:	83 c4 4c             	add    $0x4c,%esp
  802001:	5b                   	pop    %ebx
  802002:	5e                   	pop    %esi
  802003:	5f                   	pop    %edi
  802004:	5d                   	pop    %ebp
  802005:	c3                   	ret    

00802006 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  802006:	55                   	push   %ebp
  802007:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  802009:	83 fa 01             	cmp    $0x1,%edx
  80200c:	7e 0e                	jle    80201c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80200e:	8b 10                	mov    (%eax),%edx
  802010:	8d 4a 08             	lea    0x8(%edx),%ecx
  802013:	89 08                	mov    %ecx,(%eax)
  802015:	8b 02                	mov    (%edx),%eax
  802017:	8b 52 04             	mov    0x4(%edx),%edx
  80201a:	eb 22                	jmp    80203e <getuint+0x38>
	else if (lflag)
  80201c:	85 d2                	test   %edx,%edx
  80201e:	74 10                	je     802030 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  802020:	8b 10                	mov    (%eax),%edx
  802022:	8d 4a 04             	lea    0x4(%edx),%ecx
  802025:	89 08                	mov    %ecx,(%eax)
  802027:	8b 02                	mov    (%edx),%eax
  802029:	ba 00 00 00 00       	mov    $0x0,%edx
  80202e:	eb 0e                	jmp    80203e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  802030:	8b 10                	mov    (%eax),%edx
  802032:	8d 4a 04             	lea    0x4(%edx),%ecx
  802035:	89 08                	mov    %ecx,(%eax)
  802037:	8b 02                	mov    (%edx),%eax
  802039:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80203e:	5d                   	pop    %ebp
  80203f:	c3                   	ret    

00802040 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  802040:	55                   	push   %ebp
  802041:	89 e5                	mov    %esp,%ebp
  802043:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  802046:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80204a:	8b 10                	mov    (%eax),%edx
  80204c:	3b 50 04             	cmp    0x4(%eax),%edx
  80204f:	73 0a                	jae    80205b <sprintputch+0x1b>
		*b->buf++ = ch;
  802051:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802054:	88 0a                	mov    %cl,(%edx)
  802056:	83 c2 01             	add    $0x1,%edx
  802059:	89 10                	mov    %edx,(%eax)
}
  80205b:	5d                   	pop    %ebp
  80205c:	c3                   	ret    

0080205d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80205d:	55                   	push   %ebp
  80205e:	89 e5                	mov    %esp,%ebp
  802060:	57                   	push   %edi
  802061:	56                   	push   %esi
  802062:	53                   	push   %ebx
  802063:	83 ec 5c             	sub    $0x5c,%esp
  802066:	8b 7d 08             	mov    0x8(%ebp),%edi
  802069:	8b 75 0c             	mov    0xc(%ebp),%esi
  80206c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80206f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  802076:	eb 11                	jmp    802089 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  802078:	85 c0                	test   %eax,%eax
  80207a:	0f 84 f9 03 00 00    	je     802479 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  802080:	89 74 24 04          	mov    %esi,0x4(%esp)
  802084:	89 04 24             	mov    %eax,(%esp)
  802087:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  802089:	0f b6 03             	movzbl (%ebx),%eax
  80208c:	83 c3 01             	add    $0x1,%ebx
  80208f:	83 f8 25             	cmp    $0x25,%eax
  802092:	75 e4                	jne    802078 <vprintfmt+0x1b>
  802094:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  802098:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80209f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8020a6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8020ad:	b9 00 00 00 00       	mov    $0x0,%ecx
  8020b2:	eb 06                	jmp    8020ba <vprintfmt+0x5d>
  8020b4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8020b8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8020ba:	0f b6 13             	movzbl (%ebx),%edx
  8020bd:	0f b6 c2             	movzbl %dl,%eax
  8020c0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8020c3:	8d 43 01             	lea    0x1(%ebx),%eax
  8020c6:	83 ea 23             	sub    $0x23,%edx
  8020c9:	80 fa 55             	cmp    $0x55,%dl
  8020cc:	0f 87 8a 03 00 00    	ja     80245c <vprintfmt+0x3ff>
  8020d2:	0f b6 d2             	movzbl %dl,%edx
  8020d5:	ff 24 95 80 2b 80 00 	jmp    *0x802b80(,%edx,4)
  8020dc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  8020e0:	eb d6                	jmp    8020b8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  8020e2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8020e5:	83 ea 30             	sub    $0x30,%edx
  8020e8:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  8020eb:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8020ee:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8020f1:	83 fb 09             	cmp    $0x9,%ebx
  8020f4:	77 54                	ja     80214a <vprintfmt+0xed>
  8020f6:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  8020f9:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  8020fc:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  8020ff:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  802102:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  802106:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  802109:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80210c:	83 fb 09             	cmp    $0x9,%ebx
  80210f:	76 eb                	jbe    8020fc <vprintfmt+0x9f>
  802111:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  802114:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  802117:	eb 31                	jmp    80214a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  802119:	8b 55 14             	mov    0x14(%ebp),%edx
  80211c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80211f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  802122:	8b 12                	mov    (%edx),%edx
  802124:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  802127:	eb 21                	jmp    80214a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  802129:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80212d:	ba 00 00 00 00       	mov    $0x0,%edx
  802132:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  802136:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802139:	e9 7a ff ff ff       	jmp    8020b8 <vprintfmt+0x5b>
  80213e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  802145:	e9 6e ff ff ff       	jmp    8020b8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80214a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80214e:	0f 89 64 ff ff ff    	jns    8020b8 <vprintfmt+0x5b>
  802154:	8b 55 d0             	mov    -0x30(%ebp),%edx
  802157:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80215a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80215d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  802160:	e9 53 ff ff ff       	jmp    8020b8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  802165:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  802168:	e9 4b ff ff ff       	jmp    8020b8 <vprintfmt+0x5b>
  80216d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  802170:	8b 45 14             	mov    0x14(%ebp),%eax
  802173:	8d 50 04             	lea    0x4(%eax),%edx
  802176:	89 55 14             	mov    %edx,0x14(%ebp)
  802179:	89 74 24 04          	mov    %esi,0x4(%esp)
  80217d:	8b 00                	mov    (%eax),%eax
  80217f:	89 04 24             	mov    %eax,(%esp)
  802182:	ff d7                	call   *%edi
  802184:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  802187:	e9 fd fe ff ff       	jmp    802089 <vprintfmt+0x2c>
  80218c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80218f:	8b 45 14             	mov    0x14(%ebp),%eax
  802192:	8d 50 04             	lea    0x4(%eax),%edx
  802195:	89 55 14             	mov    %edx,0x14(%ebp)
  802198:	8b 00                	mov    (%eax),%eax
  80219a:	89 c2                	mov    %eax,%edx
  80219c:	c1 fa 1f             	sar    $0x1f,%edx
  80219f:	31 d0                	xor    %edx,%eax
  8021a1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8021a3:	83 f8 12             	cmp    $0x12,%eax
  8021a6:	7f 0b                	jg     8021b3 <vprintfmt+0x156>
  8021a8:	8b 14 85 e0 2c 80 00 	mov    0x802ce0(,%eax,4),%edx
  8021af:	85 d2                	test   %edx,%edx
  8021b1:	75 20                	jne    8021d3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8021b3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8021b7:	c7 44 24 08 43 2a 80 	movl   $0x802a43,0x8(%esp)
  8021be:	00 
  8021bf:	89 74 24 04          	mov    %esi,0x4(%esp)
  8021c3:	89 3c 24             	mov    %edi,(%esp)
  8021c6:	e8 36 03 00 00       	call   802501 <printfmt>
  8021cb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8021ce:	e9 b6 fe ff ff       	jmp    802089 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8021d3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8021d7:	c7 44 24 08 c2 29 80 	movl   $0x8029c2,0x8(%esp)
  8021de:	00 
  8021df:	89 74 24 04          	mov    %esi,0x4(%esp)
  8021e3:	89 3c 24             	mov    %edi,(%esp)
  8021e6:	e8 16 03 00 00       	call   802501 <printfmt>
  8021eb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8021ee:	e9 96 fe ff ff       	jmp    802089 <vprintfmt+0x2c>
  8021f3:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8021f6:	89 c3                	mov    %eax,%ebx
  8021f8:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8021fb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8021fe:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  802201:	8b 45 14             	mov    0x14(%ebp),%eax
  802204:	8d 50 04             	lea    0x4(%eax),%edx
  802207:	89 55 14             	mov    %edx,0x14(%ebp)
  80220a:	8b 00                	mov    (%eax),%eax
  80220c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80220f:	85 c0                	test   %eax,%eax
  802211:	b8 4c 2a 80 00       	mov    $0x802a4c,%eax
  802216:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80221a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80221d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  802221:	7e 06                	jle    802229 <vprintfmt+0x1cc>
  802223:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  802227:	75 13                	jne    80223c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  802229:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80222c:	0f be 02             	movsbl (%edx),%eax
  80222f:	85 c0                	test   %eax,%eax
  802231:	0f 85 9b 00 00 00    	jne    8022d2 <vprintfmt+0x275>
  802237:	e9 88 00 00 00       	jmp    8022c4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80223c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  802240:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  802243:	89 0c 24             	mov    %ecx,(%esp)
  802246:	e8 50 df ff ff       	call   80019b <strnlen>
  80224b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80224e:	29 c2                	sub    %eax,%edx
  802250:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802253:	85 d2                	test   %edx,%edx
  802255:	7e d2                	jle    802229 <vprintfmt+0x1cc>
					putch(padc, putdat);
  802257:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80225b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80225e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  802261:	89 d3                	mov    %edx,%ebx
  802263:	89 74 24 04          	mov    %esi,0x4(%esp)
  802267:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80226a:	89 04 24             	mov    %eax,(%esp)
  80226d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80226f:	83 eb 01             	sub    $0x1,%ebx
  802272:	85 db                	test   %ebx,%ebx
  802274:	7f ed                	jg     802263 <vprintfmt+0x206>
  802276:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  802279:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  802280:	eb a7                	jmp    802229 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  802282:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  802286:	74 1a                	je     8022a2 <vprintfmt+0x245>
  802288:	8d 50 e0             	lea    -0x20(%eax),%edx
  80228b:	83 fa 5e             	cmp    $0x5e,%edx
  80228e:	76 12                	jbe    8022a2 <vprintfmt+0x245>
					putch('?', putdat);
  802290:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802294:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80229b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80229e:	66 90                	xchg   %ax,%ax
  8022a0:	eb 0a                	jmp    8022ac <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8022a2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8022a6:	89 04 24             	mov    %eax,(%esp)
  8022a9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8022ac:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  8022b0:	0f be 03             	movsbl (%ebx),%eax
  8022b3:	85 c0                	test   %eax,%eax
  8022b5:	74 05                	je     8022bc <vprintfmt+0x25f>
  8022b7:	83 c3 01             	add    $0x1,%ebx
  8022ba:	eb 29                	jmp    8022e5 <vprintfmt+0x288>
  8022bc:	89 fe                	mov    %edi,%esi
  8022be:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8022c1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8022c4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8022c8:	7f 2e                	jg     8022f8 <vprintfmt+0x29b>
  8022ca:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8022cd:	e9 b7 fd ff ff       	jmp    802089 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8022d2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8022d5:	83 c2 01             	add    $0x1,%edx
  8022d8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8022db:	89 f7                	mov    %esi,%edi
  8022dd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  8022e0:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  8022e3:	89 d3                	mov    %edx,%ebx
  8022e5:	85 f6                	test   %esi,%esi
  8022e7:	78 99                	js     802282 <vprintfmt+0x225>
  8022e9:	83 ee 01             	sub    $0x1,%esi
  8022ec:	79 94                	jns    802282 <vprintfmt+0x225>
  8022ee:	89 fe                	mov    %edi,%esi
  8022f0:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8022f3:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  8022f6:	eb cc                	jmp    8022c4 <vprintfmt+0x267>
  8022f8:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  8022fb:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  8022fe:	89 74 24 04          	mov    %esi,0x4(%esp)
  802302:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  802309:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80230b:	83 eb 01             	sub    $0x1,%ebx
  80230e:	85 db                	test   %ebx,%ebx
  802310:	7f ec                	jg     8022fe <vprintfmt+0x2a1>
  802312:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  802315:	e9 6f fd ff ff       	jmp    802089 <vprintfmt+0x2c>
  80231a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80231d:	83 f9 01             	cmp    $0x1,%ecx
  802320:	7e 16                	jle    802338 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  802322:	8b 45 14             	mov    0x14(%ebp),%eax
  802325:	8d 50 08             	lea    0x8(%eax),%edx
  802328:	89 55 14             	mov    %edx,0x14(%ebp)
  80232b:	8b 10                	mov    (%eax),%edx
  80232d:	8b 48 04             	mov    0x4(%eax),%ecx
  802330:	89 55 d8             	mov    %edx,-0x28(%ebp)
  802333:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  802336:	eb 32                	jmp    80236a <vprintfmt+0x30d>
	else if (lflag)
  802338:	85 c9                	test   %ecx,%ecx
  80233a:	74 18                	je     802354 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80233c:	8b 45 14             	mov    0x14(%ebp),%eax
  80233f:	8d 50 04             	lea    0x4(%eax),%edx
  802342:	89 55 14             	mov    %edx,0x14(%ebp)
  802345:	8b 00                	mov    (%eax),%eax
  802347:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80234a:	89 c1                	mov    %eax,%ecx
  80234c:	c1 f9 1f             	sar    $0x1f,%ecx
  80234f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  802352:	eb 16                	jmp    80236a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  802354:	8b 45 14             	mov    0x14(%ebp),%eax
  802357:	8d 50 04             	lea    0x4(%eax),%edx
  80235a:	89 55 14             	mov    %edx,0x14(%ebp)
  80235d:	8b 00                	mov    (%eax),%eax
  80235f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  802362:	89 c2                	mov    %eax,%edx
  802364:	c1 fa 1f             	sar    $0x1f,%edx
  802367:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80236a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80236d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  802370:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  802375:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  802379:	0f 89 9b 00 00 00    	jns    80241a <vprintfmt+0x3bd>
				putch('-', putdat);
  80237f:	89 74 24 04          	mov    %esi,0x4(%esp)
  802383:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80238a:	ff d7                	call   *%edi
				num = -(long long) num;
  80238c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80238f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  802392:	f7 d9                	neg    %ecx
  802394:	83 d3 00             	adc    $0x0,%ebx
  802397:	f7 db                	neg    %ebx
  802399:	b8 0a 00 00 00       	mov    $0xa,%eax
  80239e:	eb 7a                	jmp    80241a <vprintfmt+0x3bd>
  8023a0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8023a3:	89 ca                	mov    %ecx,%edx
  8023a5:	8d 45 14             	lea    0x14(%ebp),%eax
  8023a8:	e8 59 fc ff ff       	call   802006 <getuint>
  8023ad:	89 c1                	mov    %eax,%ecx
  8023af:	89 d3                	mov    %edx,%ebx
  8023b1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8023b6:	eb 62                	jmp    80241a <vprintfmt+0x3bd>
  8023b8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8023bb:	89 ca                	mov    %ecx,%edx
  8023bd:	8d 45 14             	lea    0x14(%ebp),%eax
  8023c0:	e8 41 fc ff ff       	call   802006 <getuint>
  8023c5:	89 c1                	mov    %eax,%ecx
  8023c7:	89 d3                	mov    %edx,%ebx
  8023c9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8023ce:	eb 4a                	jmp    80241a <vprintfmt+0x3bd>
  8023d0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8023d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8023d7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8023de:	ff d7                	call   *%edi
			putch('x', putdat);
  8023e0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8023e4:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  8023eb:	ff d7                	call   *%edi
			num = (unsigned long long)
  8023ed:	8b 45 14             	mov    0x14(%ebp),%eax
  8023f0:	8d 50 04             	lea    0x4(%eax),%edx
  8023f3:	89 55 14             	mov    %edx,0x14(%ebp)
  8023f6:	8b 08                	mov    (%eax),%ecx
  8023f8:	bb 00 00 00 00       	mov    $0x0,%ebx
  8023fd:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  802402:	eb 16                	jmp    80241a <vprintfmt+0x3bd>
  802404:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  802407:	89 ca                	mov    %ecx,%edx
  802409:	8d 45 14             	lea    0x14(%ebp),%eax
  80240c:	e8 f5 fb ff ff       	call   802006 <getuint>
  802411:	89 c1                	mov    %eax,%ecx
  802413:	89 d3                	mov    %edx,%ebx
  802415:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80241a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80241e:	89 54 24 10          	mov    %edx,0x10(%esp)
  802422:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802425:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802429:	89 44 24 08          	mov    %eax,0x8(%esp)
  80242d:	89 0c 24             	mov    %ecx,(%esp)
  802430:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802434:	89 f2                	mov    %esi,%edx
  802436:	89 f8                	mov    %edi,%eax
  802438:	e8 d3 fa ff ff       	call   801f10 <printnum>
  80243d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  802440:	e9 44 fc ff ff       	jmp    802089 <vprintfmt+0x2c>
  802445:	89 45 cc             	mov    %eax,-0x34(%ebp)
  802448:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80244b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80244f:	89 14 24             	mov    %edx,(%esp)
  802452:	ff d7                	call   *%edi
  802454:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  802457:	e9 2d fc ff ff       	jmp    802089 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80245c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802460:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  802467:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  802469:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80246c:	80 38 25             	cmpb   $0x25,(%eax)
  80246f:	0f 84 14 fc ff ff    	je     802089 <vprintfmt+0x2c>
  802475:	89 c3                	mov    %eax,%ebx
  802477:	eb f0                	jmp    802469 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  802479:	83 c4 5c             	add    $0x5c,%esp
  80247c:	5b                   	pop    %ebx
  80247d:	5e                   	pop    %esi
  80247e:	5f                   	pop    %edi
  80247f:	5d                   	pop    %ebp
  802480:	c3                   	ret    

00802481 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  802481:	55                   	push   %ebp
  802482:	89 e5                	mov    %esp,%ebp
  802484:	83 ec 28             	sub    $0x28,%esp
  802487:	8b 45 08             	mov    0x8(%ebp),%eax
  80248a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  80248d:	85 c0                	test   %eax,%eax
  80248f:	74 04                	je     802495 <vsnprintf+0x14>
  802491:	85 d2                	test   %edx,%edx
  802493:	7f 07                	jg     80249c <vsnprintf+0x1b>
  802495:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80249a:	eb 3b                	jmp    8024d7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  80249c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  80249f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8024a3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8024a6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8024ad:	8b 45 14             	mov    0x14(%ebp),%eax
  8024b0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8024b4:	8b 45 10             	mov    0x10(%ebp),%eax
  8024b7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024bb:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8024be:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024c2:	c7 04 24 40 20 80 00 	movl   $0x802040,(%esp)
  8024c9:	e8 8f fb ff ff       	call   80205d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8024ce:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8024d1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8024d4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8024d7:	c9                   	leave  
  8024d8:	c3                   	ret    

008024d9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8024d9:	55                   	push   %ebp
  8024da:	89 e5                	mov    %esp,%ebp
  8024dc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8024df:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  8024e2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8024e6:	8b 45 10             	mov    0x10(%ebp),%eax
  8024e9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024ed:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024f0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024f4:	8b 45 08             	mov    0x8(%ebp),%eax
  8024f7:	89 04 24             	mov    %eax,(%esp)
  8024fa:	e8 82 ff ff ff       	call   802481 <vsnprintf>
	va_end(ap);

	return rc;
}
  8024ff:	c9                   	leave  
  802500:	c3                   	ret    

00802501 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  802501:	55                   	push   %ebp
  802502:	89 e5                	mov    %esp,%ebp
  802504:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  802507:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80250a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80250e:	8b 45 10             	mov    0x10(%ebp),%eax
  802511:	89 44 24 08          	mov    %eax,0x8(%esp)
  802515:	8b 45 0c             	mov    0xc(%ebp),%eax
  802518:	89 44 24 04          	mov    %eax,0x4(%esp)
  80251c:	8b 45 08             	mov    0x8(%ebp),%eax
  80251f:	89 04 24             	mov    %eax,(%esp)
  802522:	e8 36 fb ff ff       	call   80205d <vprintfmt>
	va_end(ap);
}
  802527:	c9                   	leave  
  802528:	c3                   	ret    
  802529:	00 00                	add    %al,(%eax)
  80252b:	00 00                	add    %al,(%eax)
  80252d:	00 00                	add    %al,(%eax)
	...

00802530 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802530:	55                   	push   %ebp
  802531:	89 e5                	mov    %esp,%ebp
  802533:	57                   	push   %edi
  802534:	56                   	push   %esi
  802535:	53                   	push   %ebx
  802536:	83 ec 2c             	sub    $0x2c,%esp
  802539:	8b 75 08             	mov    0x8(%ebp),%esi
  80253c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80253f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802542:	85 db                	test   %ebx,%ebx
  802544:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802549:	0f 45 c3             	cmovne %ebx,%eax
  80254c:	8b 55 14             	mov    0x14(%ebp),%edx
  80254f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802553:	89 44 24 08          	mov    %eax,0x8(%esp)
  802557:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80255b:	89 34 24             	mov    %esi,(%esp)
  80255e:	e8 8d e1 ff ff       	call   8006f0 <sys_ipc_try_send>
  802563:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802566:	75 0a                	jne    802572 <ipc_send+0x42>
      sys_yield();
  802568:	e8 18 e4 ff ff       	call   800985 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80256d:	8d 76 00             	lea    0x0(%esi),%esi
  802570:	eb d0                	jmp    802542 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802572:	85 c0                	test   %eax,%eax
  802574:	79 24                	jns    80259a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802576:	89 44 24 10          	mov    %eax,0x10(%esp)
  80257a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80257e:	c7 44 24 08 4c 2d 80 	movl   $0x802d4c,0x8(%esp)
  802585:	00 
  802586:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80258d:	00 
  80258e:	c7 04 24 70 2d 80 00 	movl   $0x802d70,(%esp)
  802595:	e8 4a f8 ff ff       	call   801de4 <_panic>
    else
      return;
  }
}
  80259a:	83 c4 2c             	add    $0x2c,%esp
  80259d:	5b                   	pop    %ebx
  80259e:	5e                   	pop    %esi
  80259f:	5f                   	pop    %edi
  8025a0:	5d                   	pop    %ebp
  8025a1:	c3                   	ret    

008025a2 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  8025a2:	55                   	push   %ebp
  8025a3:	89 e5                	mov    %esp,%ebp
  8025a5:	56                   	push   %esi
  8025a6:	53                   	push   %ebx
  8025a7:	83 ec 10             	sub    $0x10,%esp
  8025aa:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8025ad:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025b0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  8025b3:	85 c0                	test   %eax,%eax
  8025b5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8025ba:	0f 44 c2             	cmove  %edx,%eax
  8025bd:	89 04 24             	mov    %eax,(%esp)
  8025c0:	e8 ce e0 ff ff       	call   800693 <sys_ipc_recv>
  8025c5:	85 c0                	test   %eax,%eax
  8025c7:	78 24                	js     8025ed <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  8025c9:	85 db                	test   %ebx,%ebx
  8025cb:	74 0a                	je     8025d7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  8025cd:	a1 74 60 80 00       	mov    0x806074,%eax
  8025d2:	8b 40 74             	mov    0x74(%eax),%eax
  8025d5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  8025d7:	85 f6                	test   %esi,%esi
  8025d9:	74 0a                	je     8025e5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  8025db:	a1 74 60 80 00       	mov    0x806074,%eax
  8025e0:	8b 40 78             	mov    0x78(%eax),%eax
  8025e3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8025e5:	a1 74 60 80 00       	mov    0x806074,%eax
  8025ea:	8b 40 70             	mov    0x70(%eax),%eax
}
  8025ed:	83 c4 10             	add    $0x10,%esp
  8025f0:	5b                   	pop    %ebx
  8025f1:	5e                   	pop    %esi
  8025f2:	5d                   	pop    %ebp
  8025f3:	c3                   	ret    

008025f4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8025f4:	55                   	push   %ebp
  8025f5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  8025f7:	8b 45 08             	mov    0x8(%ebp),%eax
  8025fa:	89 c2                	mov    %eax,%edx
  8025fc:	c1 ea 16             	shr    $0x16,%edx
  8025ff:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802606:	f6 c2 01             	test   $0x1,%dl
  802609:	74 26                	je     802631 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  80260b:	c1 e8 0c             	shr    $0xc,%eax
  80260e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802615:	a8 01                	test   $0x1,%al
  802617:	74 18                	je     802631 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802619:	c1 e8 0c             	shr    $0xc,%eax
  80261c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  80261f:	c1 e2 02             	shl    $0x2,%edx
  802622:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802627:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  80262c:	0f b7 c0             	movzwl %ax,%eax
  80262f:	eb 05                	jmp    802636 <pageref+0x42>
  802631:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802636:	5d                   	pop    %ebp
  802637:	c3                   	ret    
	...

00802640 <__udivdi3>:
  802640:	55                   	push   %ebp
  802641:	89 e5                	mov    %esp,%ebp
  802643:	57                   	push   %edi
  802644:	56                   	push   %esi
  802645:	83 ec 10             	sub    $0x10,%esp
  802648:	8b 45 14             	mov    0x14(%ebp),%eax
  80264b:	8b 55 08             	mov    0x8(%ebp),%edx
  80264e:	8b 75 10             	mov    0x10(%ebp),%esi
  802651:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802654:	85 c0                	test   %eax,%eax
  802656:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802659:	75 35                	jne    802690 <__udivdi3+0x50>
  80265b:	39 fe                	cmp    %edi,%esi
  80265d:	77 61                	ja     8026c0 <__udivdi3+0x80>
  80265f:	85 f6                	test   %esi,%esi
  802661:	75 0b                	jne    80266e <__udivdi3+0x2e>
  802663:	b8 01 00 00 00       	mov    $0x1,%eax
  802668:	31 d2                	xor    %edx,%edx
  80266a:	f7 f6                	div    %esi
  80266c:	89 c6                	mov    %eax,%esi
  80266e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802671:	31 d2                	xor    %edx,%edx
  802673:	89 f8                	mov    %edi,%eax
  802675:	f7 f6                	div    %esi
  802677:	89 c7                	mov    %eax,%edi
  802679:	89 c8                	mov    %ecx,%eax
  80267b:	f7 f6                	div    %esi
  80267d:	89 c1                	mov    %eax,%ecx
  80267f:	89 fa                	mov    %edi,%edx
  802681:	89 c8                	mov    %ecx,%eax
  802683:	83 c4 10             	add    $0x10,%esp
  802686:	5e                   	pop    %esi
  802687:	5f                   	pop    %edi
  802688:	5d                   	pop    %ebp
  802689:	c3                   	ret    
  80268a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802690:	39 f8                	cmp    %edi,%eax
  802692:	77 1c                	ja     8026b0 <__udivdi3+0x70>
  802694:	0f bd d0             	bsr    %eax,%edx
  802697:	83 f2 1f             	xor    $0x1f,%edx
  80269a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80269d:	75 39                	jne    8026d8 <__udivdi3+0x98>
  80269f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  8026a2:	0f 86 a0 00 00 00    	jbe    802748 <__udivdi3+0x108>
  8026a8:	39 f8                	cmp    %edi,%eax
  8026aa:	0f 82 98 00 00 00    	jb     802748 <__udivdi3+0x108>
  8026b0:	31 ff                	xor    %edi,%edi
  8026b2:	31 c9                	xor    %ecx,%ecx
  8026b4:	89 c8                	mov    %ecx,%eax
  8026b6:	89 fa                	mov    %edi,%edx
  8026b8:	83 c4 10             	add    $0x10,%esp
  8026bb:	5e                   	pop    %esi
  8026bc:	5f                   	pop    %edi
  8026bd:	5d                   	pop    %ebp
  8026be:	c3                   	ret    
  8026bf:	90                   	nop
  8026c0:	89 d1                	mov    %edx,%ecx
  8026c2:	89 fa                	mov    %edi,%edx
  8026c4:	89 c8                	mov    %ecx,%eax
  8026c6:	31 ff                	xor    %edi,%edi
  8026c8:	f7 f6                	div    %esi
  8026ca:	89 c1                	mov    %eax,%ecx
  8026cc:	89 fa                	mov    %edi,%edx
  8026ce:	89 c8                	mov    %ecx,%eax
  8026d0:	83 c4 10             	add    $0x10,%esp
  8026d3:	5e                   	pop    %esi
  8026d4:	5f                   	pop    %edi
  8026d5:	5d                   	pop    %ebp
  8026d6:	c3                   	ret    
  8026d7:	90                   	nop
  8026d8:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8026dc:	89 f2                	mov    %esi,%edx
  8026de:	d3 e0                	shl    %cl,%eax
  8026e0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8026e3:	b8 20 00 00 00       	mov    $0x20,%eax
  8026e8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  8026eb:	89 c1                	mov    %eax,%ecx
  8026ed:	d3 ea                	shr    %cl,%edx
  8026ef:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8026f3:	0b 55 ec             	or     -0x14(%ebp),%edx
  8026f6:	d3 e6                	shl    %cl,%esi
  8026f8:	89 c1                	mov    %eax,%ecx
  8026fa:	89 75 e8             	mov    %esi,-0x18(%ebp)
  8026fd:	89 fe                	mov    %edi,%esi
  8026ff:	d3 ee                	shr    %cl,%esi
  802701:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802705:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802708:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80270b:	d3 e7                	shl    %cl,%edi
  80270d:	89 c1                	mov    %eax,%ecx
  80270f:	d3 ea                	shr    %cl,%edx
  802711:	09 d7                	or     %edx,%edi
  802713:	89 f2                	mov    %esi,%edx
  802715:	89 f8                	mov    %edi,%eax
  802717:	f7 75 ec             	divl   -0x14(%ebp)
  80271a:	89 d6                	mov    %edx,%esi
  80271c:	89 c7                	mov    %eax,%edi
  80271e:	f7 65 e8             	mull   -0x18(%ebp)
  802721:	39 d6                	cmp    %edx,%esi
  802723:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802726:	72 30                	jb     802758 <__udivdi3+0x118>
  802728:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80272b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80272f:	d3 e2                	shl    %cl,%edx
  802731:	39 c2                	cmp    %eax,%edx
  802733:	73 05                	jae    80273a <__udivdi3+0xfa>
  802735:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802738:	74 1e                	je     802758 <__udivdi3+0x118>
  80273a:	89 f9                	mov    %edi,%ecx
  80273c:	31 ff                	xor    %edi,%edi
  80273e:	e9 71 ff ff ff       	jmp    8026b4 <__udivdi3+0x74>
  802743:	90                   	nop
  802744:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802748:	31 ff                	xor    %edi,%edi
  80274a:	b9 01 00 00 00       	mov    $0x1,%ecx
  80274f:	e9 60 ff ff ff       	jmp    8026b4 <__udivdi3+0x74>
  802754:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802758:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80275b:	31 ff                	xor    %edi,%edi
  80275d:	89 c8                	mov    %ecx,%eax
  80275f:	89 fa                	mov    %edi,%edx
  802761:	83 c4 10             	add    $0x10,%esp
  802764:	5e                   	pop    %esi
  802765:	5f                   	pop    %edi
  802766:	5d                   	pop    %ebp
  802767:	c3                   	ret    
	...

00802770 <__umoddi3>:
  802770:	55                   	push   %ebp
  802771:	89 e5                	mov    %esp,%ebp
  802773:	57                   	push   %edi
  802774:	56                   	push   %esi
  802775:	83 ec 20             	sub    $0x20,%esp
  802778:	8b 55 14             	mov    0x14(%ebp),%edx
  80277b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80277e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802781:	8b 75 0c             	mov    0xc(%ebp),%esi
  802784:	85 d2                	test   %edx,%edx
  802786:	89 c8                	mov    %ecx,%eax
  802788:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80278b:	75 13                	jne    8027a0 <__umoddi3+0x30>
  80278d:	39 f7                	cmp    %esi,%edi
  80278f:	76 3f                	jbe    8027d0 <__umoddi3+0x60>
  802791:	89 f2                	mov    %esi,%edx
  802793:	f7 f7                	div    %edi
  802795:	89 d0                	mov    %edx,%eax
  802797:	31 d2                	xor    %edx,%edx
  802799:	83 c4 20             	add    $0x20,%esp
  80279c:	5e                   	pop    %esi
  80279d:	5f                   	pop    %edi
  80279e:	5d                   	pop    %ebp
  80279f:	c3                   	ret    
  8027a0:	39 f2                	cmp    %esi,%edx
  8027a2:	77 4c                	ja     8027f0 <__umoddi3+0x80>
  8027a4:	0f bd ca             	bsr    %edx,%ecx
  8027a7:	83 f1 1f             	xor    $0x1f,%ecx
  8027aa:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  8027ad:	75 51                	jne    802800 <__umoddi3+0x90>
  8027af:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  8027b2:	0f 87 e0 00 00 00    	ja     802898 <__umoddi3+0x128>
  8027b8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027bb:	29 f8                	sub    %edi,%eax
  8027bd:	19 d6                	sbb    %edx,%esi
  8027bf:	89 45 f4             	mov    %eax,-0xc(%ebp)
  8027c2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027c5:	89 f2                	mov    %esi,%edx
  8027c7:	83 c4 20             	add    $0x20,%esp
  8027ca:	5e                   	pop    %esi
  8027cb:	5f                   	pop    %edi
  8027cc:	5d                   	pop    %ebp
  8027cd:	c3                   	ret    
  8027ce:	66 90                	xchg   %ax,%ax
  8027d0:	85 ff                	test   %edi,%edi
  8027d2:	75 0b                	jne    8027df <__umoddi3+0x6f>
  8027d4:	b8 01 00 00 00       	mov    $0x1,%eax
  8027d9:	31 d2                	xor    %edx,%edx
  8027db:	f7 f7                	div    %edi
  8027dd:	89 c7                	mov    %eax,%edi
  8027df:	89 f0                	mov    %esi,%eax
  8027e1:	31 d2                	xor    %edx,%edx
  8027e3:	f7 f7                	div    %edi
  8027e5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027e8:	f7 f7                	div    %edi
  8027ea:	eb a9                	jmp    802795 <__umoddi3+0x25>
  8027ec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8027f0:	89 c8                	mov    %ecx,%eax
  8027f2:	89 f2                	mov    %esi,%edx
  8027f4:	83 c4 20             	add    $0x20,%esp
  8027f7:	5e                   	pop    %esi
  8027f8:	5f                   	pop    %edi
  8027f9:	5d                   	pop    %ebp
  8027fa:	c3                   	ret    
  8027fb:	90                   	nop
  8027fc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802800:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802804:	d3 e2                	shl    %cl,%edx
  802806:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802809:	ba 20 00 00 00       	mov    $0x20,%edx
  80280e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802811:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802814:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802818:	89 fa                	mov    %edi,%edx
  80281a:	d3 ea                	shr    %cl,%edx
  80281c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802820:	0b 55 f4             	or     -0xc(%ebp),%edx
  802823:	d3 e7                	shl    %cl,%edi
  802825:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802829:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80282c:	89 f2                	mov    %esi,%edx
  80282e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802831:	89 c7                	mov    %eax,%edi
  802833:	d3 ea                	shr    %cl,%edx
  802835:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802839:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80283c:	89 c2                	mov    %eax,%edx
  80283e:	d3 e6                	shl    %cl,%esi
  802840:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802844:	d3 ea                	shr    %cl,%edx
  802846:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80284a:	09 d6                	or     %edx,%esi
  80284c:	89 f0                	mov    %esi,%eax
  80284e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802851:	d3 e7                	shl    %cl,%edi
  802853:	89 f2                	mov    %esi,%edx
  802855:	f7 75 f4             	divl   -0xc(%ebp)
  802858:	89 d6                	mov    %edx,%esi
  80285a:	f7 65 e8             	mull   -0x18(%ebp)
  80285d:	39 d6                	cmp    %edx,%esi
  80285f:	72 2b                	jb     80288c <__umoddi3+0x11c>
  802861:	39 c7                	cmp    %eax,%edi
  802863:	72 23                	jb     802888 <__umoddi3+0x118>
  802865:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802869:	29 c7                	sub    %eax,%edi
  80286b:	19 d6                	sbb    %edx,%esi
  80286d:	89 f0                	mov    %esi,%eax
  80286f:	89 f2                	mov    %esi,%edx
  802871:	d3 ef                	shr    %cl,%edi
  802873:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802877:	d3 e0                	shl    %cl,%eax
  802879:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80287d:	09 f8                	or     %edi,%eax
  80287f:	d3 ea                	shr    %cl,%edx
  802881:	83 c4 20             	add    $0x20,%esp
  802884:	5e                   	pop    %esi
  802885:	5f                   	pop    %edi
  802886:	5d                   	pop    %ebp
  802887:	c3                   	ret    
  802888:	39 d6                	cmp    %edx,%esi
  80288a:	75 d9                	jne    802865 <__umoddi3+0xf5>
  80288c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80288f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802892:	eb d1                	jmp    802865 <__umoddi3+0xf5>
  802894:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802898:	39 f2                	cmp    %esi,%edx
  80289a:	0f 82 18 ff ff ff    	jb     8027b8 <__umoddi3+0x48>
  8028a0:	e9 1d ff ff ff       	jmp    8027c2 <__umoddi3+0x52>
